ToBoxedDyn

Trait ToBoxedDyn 

Source
pub unsafe trait ToBoxedDyn<T: ?Sized> {
    // Required method
    fn to_boxed_unsize(value: Self) -> Box<T>;
}
Expand description

Trait to construct a Box<dyn Trait> from a type implementing Unsize<dyn Trait>.

Since Unsize<T> is gated behind the unsize nightly feature, on stable Rust this trait is only implemented for:

Enable the unstable feature to support all possible coercions.

§Safety

  • T must be some trait object type dyn Trait + Markers + 'a, where Markers are optional marker traits (e.g. Send and Sync).
  • Given the same T as above, implementers must also implement Trait, Markers and outlive 'a.

Required Methods§

Source

fn to_boxed_unsize(value: Self) -> Box<T>

Constructs a Box<T> from Self, coercing into the unsized type.

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.

Implementors§

Source§

impl<'a, T: 'a> ToBoxedDyn<dyn Any + 'a> for T

Available on non-crate feature unstable only.
Source§

impl<'a, T: Send + 'a> ToBoxedDyn<dyn Send + 'a> for T

Available on non-crate feature unstable only.
Source§

impl<'a, T: Send + Sync + 'a> ToBoxedDyn<dyn Send + Sync + 'a> for T

Available on non-crate feature unstable only.
Source§

impl<'a, T: Sync + 'a> ToBoxedDyn<dyn Sync + 'a> for T

Available on non-crate feature unstable only.