Converts a class pointer to a base class pointer.
A null pointer is always converted to a null pointer. Otherwise, the provided pointer must be valid.
It's recommended to perform the conversion by calling
method on pointer types (
instead of importing the trait directly.
Provides access to C++
static_cast conversion from derived class to base class.
The conversion in opposite direction can be done with
T1 class is derived (in C++) from
T2 class (directly or indirectly),
StaticUpcast<T2> is implemented for
The implementation is generated by
Note that Rust functions associated with this trait have runtime overhead.
static_cast is usually a no-op if there is no multiple inheritance,
and multiple inheritance requires pointer adjustment. However, Rust compiler
ritual do not have any information about these implementation details,
so all calls of
static_cast are wrapper in FFI functions.
unsafe fn static_upcast(ptr: Ptr<Self>) -> Ptr<T>
Convert type of a const pointer.
This operation is safe as long as
ptr is either valid or null.