pub trait UpcastFrom<S: ?Sized> { }Expand description
A trait for defining upcast relationships from a source type.
This is the inverse of Upcast<T> - instead of implementing
impl Upcast<Target> for Source, you implement impl UpcastFrom<Source> for Target.
§Why UpcastFrom?
This resolves Rust’s orphan rule issues: you can implement UpcastFrom<MyType>
for external types when MyType is local to your crate, whereas implementing
Upcast<ExternalType> would be prohibited by orphan rules.
§⚠️ Unstable
This is part of the internal convert module, no
stability guarantees are provided. Use at your own risk. See its
documentation for more details.
§Relationship to Upcast
UpcastFrom<S> provides a blanket implementation of Upcast<T>:
impl<S, T> Upcast<T> for S where T: UpcastFrom<S> {}This means implementing UpcastFrom<Source> for Target automatically gives you
Upcast<Target> for Source, enabling source.upcast() to produce Target.