Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upNot able to infer equality in some special cases #16
Comments
bvssvni
added
the
bug
label
Jul 26, 2015
This comment has been minimized.
This comment has been minimized.
|
A similar error can be replicated in the_simpsons example: fn foo<T: HasChildren>(a: T) -> T::Father { a.cutest().father() }
|
bvssvni
referenced this issue
Jul 26, 2015
Closed
Constrain all the back-end type under a single trait #700
This comment has been minimized.
This comment has been minimized.
|
One solution could be to generate methods on the backend that converts the type safely. |
This comment has been minimized.
This comment has been minimized.
|
It is possible to create an unsafe trait like this: pub unsafe trait Cast<T, U> {
fn cast(a: T) -> U {
unsafe { ::std::mem::transmute_copy(&a) }
}
}
unsafe impl<T> Cast<<<T as OfBackend>::Kids as OfBackend>::Father, T::Father> for T
where T: OfBackend
{}fn foo<T: HasChildren>(a: T) -> T::Father { T::cast(a.cutest().father()) }However, this does not work for The impls will conflict, preventing one from supporting more than one cast method. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
bvssvni commentedJul 26, 2015
Example: