-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't Unify Super Generic Code #31580
Comments
@jonas-schievink Yes, I think you're right -- the projection works if you define a helper like: fn project<O>(v: Vec<O>) -> <Vec_ as TypeToType<O>>::Output {
v
} |
Actually, I was a bit too hasty: HRTBs are not clearly at fault here, since there's no lifetime involved in the |
The full fix, to be clear: fn project_vec<O>(v: Vec<O>) -> <Vec_ as TypeToType<O>>::Output {
v
}
impl<T> Mappable for Vec<T> {
type E = T;
type HKT = Vec_;
fn map<F, O>(self, mut f: F) -> <Self::HKT as TypeToType<O>>::Output
where F: FnMut(Self::E) -> O,
Self::HKT: TypeToType<O>
{
let r: Vec<O> = self.into_iter().map(&mut f).collect();
project_vec::<O>(r)
}
} But this shouldn't be necessary. |
Triage: the given code still fails to compile as of Rust 1.41. Error message:
|
I was trying to verify that the associated-items-based HKT described in the associated items RFC still worked. As best I know, I updated everything to work with today's stable Rust (1.7), but it fails out in unifying in the actual implementation of
Mappable for Vec<T>
(see the FIXME).The text was updated successfully, but these errors were encountered: