You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Even if the trait in the example declares a bound for its associated type, we have to repeat it to have the code compile.
Remove the where <T as HasNumber>::N: SignedInt and we get a compilation error:
type `<T as HasNumber>::N` does not implement any method in scope named `abs`
use std::num::SignedInt;traitHasNumber{typeN:SignedInt;fnnumber(&self) -> Self::N;}fnuser<T>(x:T)whereT:HasNumber,
<TasHasNumber>::N:SignedInt,{let n = x.number();// ok// without the repeated bound on T::N, we get this:let nabs = n.abs();// type `<T as HasNumber>::N` does not implement any method in scope named `abs`}fnmain(){}
Even if the trait in the example declares a bound for its associated type, we have to repeat it to have the code compile.
Remove the
where <T as HasNumber>::N: SignedInt
and we get a compilation error:rustc version:
cc @nikomatsakis
The text was updated successfully, but these errors were encountered: