Local type aliases to concrete types
Nobody has claimed this yet.
- Dominant language
- Markdown
- Stars
- 6.6k
- Forks
- 1.7k
- Avg merge
- 16h 14m
- Merged PRs (30d)
- 1
Description
struct Foo<T>(T);
fn test<T, U>() {
type A = Foo<T>;
type B = Foo<U>;
let a = A::method();
let b = B::method();
// and so on...
}
This is not possible because of an error: can't use type parameters from outer function; try using a local type parameter instead.
There are probably good reasons for this error but I really think there should be a way to accomplish this kind of aliasing. Otherwise it makes some code noisy and hard to read:
let a = Foo::<T>::method();
let b = Foo::<U>::method();
...especially when you use Foo<T> and Foo<U> a lot.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with issue #1697 and the linked compiler error, then review Rust's rules for local type aliases and outer function type parameters. Compare the requested aliases with the equivalent explicit generic types and document the constraints a workable solution would need. Done would be an agreed design or RFC direction, not merely a localized edit.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100