pub trait ObjectRefCast: ObjectRefCore + AnyCompatible {
// Provided method
fn try_cast<B>(self) -> Result<B>
where B: ObjectRefCore + AnyCompatible { ... }
}Expand description
Runtime-checked casting between arbitrary ObjectRef types.
The cast uses the target’s AnyCompatible::check_any_strict implementation,
mirroring the semantics of ObjectRef::as<T> in C++. This supports both
object hierarchies and parameterized object containers.
This trait is blanket-implemented for every ObjectRefCore type that is
also AnyCompatible.
Provided Methods§
Sourcefn try_cast<B>(self) -> Result<B>where
B: ObjectRefCore + AnyCompatible,
fn try_cast<B>(self) -> Result<B>where
B: ObjectRefCore + AnyCompatible,
Consume self and rewrap the underlying object as B without copying.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.