Is it possible to create an alias for features with the specified related types? I am using a method from a similar question Alias ββtype for several attributes
trait Trait { type Item; } fn print<T>(value: T) where T: Trait<Item=char> { } trait Alias: Trait {} impl<T: Trait<Item=char>> Alias for T {} fn print_alias<T: Alias>(value: T) { print(value) } fn main() { }
However, it cannot compile with the following error:
<anon>:12:5: 12:10 error: type mismatch resolving `<T as Trait>::Item == char`: expected associated type, found char [E0271] <anon>:12 print(value) ^~~~~ <anon>:12:5: 12:10 note: required by `print` <anon>:12 print(value) ^~~~~ error: aborting due to previous error
Link to play: http://is.gd/LE4h6a
rust
Mike Krasnenkov
source share