Dynamic

Trait Dynamic 

Source
pub trait Dynamic<B: IsBound>: Sealed<B> {
    // Required methods
    unsafe fn clone_unchecked(this: &Self) -> Self
       where Self: Sized;
    unsafe fn debug_unchecked(
        this: &Self,
        f: &mut Formatter<'_>,
    ) -> Result<(), Error>;

    // Provided methods
    fn clone(this: &Self) -> Self
       where Self: Sized,
             <B as IsBound>::CloneMarker: Clone { ... }
    fn debug(this: &Self, f: &mut Formatter<'_>) -> Result<(), Error>
       where Self: Sized,
             <B as IsBound>::DebugMarker: Debug { ... }
}
Expand description

Trait implemented when the bound given by B is satisfied by Self.

Use this trait in combination with Bound to apply a trait bound based on a generic type.

use dungeon_cell::bound::{Dynamic, bounds};
use dungeon_cell::marker_traits::IsBound;

fn test<T: Dynamic<B>, B: IsBound>() {}

// this failes because String isn't Copy
test::<String, bounds::Copy>();

The traits with functionality (Clone and Debug) have their implementation for the type available as Self::clone() and Self::debug(). If the type doesn’t implement one or both of these traits then it’s method will be implemented with unreachable_unchecked().

This trait is sealed and cannot be implemented outside of the implementations here.

Required Methods§

Source

unsafe fn clone_unchecked(this: &Self) -> Self
where Self: Sized,

Unsafe form of Self::clone().

This method is only valid to call if B has Clone as part of it’s bound.

§Safety

This function must only be called if B::BOUND_BY_CLONE == true and/or B::CloneMarker: Clone.

Source

unsafe fn debug_unchecked( this: &Self, f: &mut Formatter<'_>, ) -> Result<(), Error>

Unsafe form of Self::debug().

This method is only valid to call if B has Debug as part of it’s bound.

§Safety

This function must only be called if B::BOUND_BY_DEBUG == true and/or B::DebugMarker: Debug.

Provided Methods§

Source

fn clone(this: &Self) -> Self
where Self: Sized, <B as IsBound>::CloneMarker: Clone,

Call the Clone::clone() implementation of Self.

This method is always safe to call because it’s bounded by the bound including Clone. To emulate specialization, use Self::clone_unchecked and check the B::BOUND_BY_CLONE flag at runtime.

Source

fn debug(this: &Self, f: &mut Formatter<'_>) -> Result<(), Error>
where Self: Sized, <B as IsBound>::DebugMarker: Debug,

Call the Debug::fmt() implementation of Self.

This method is always safe to call because it’s bounded by the bound including Debug. To emulate specialization, use Self::debug_unchecked and check the B::BOUND_BY_DEBUG flag at runtime.

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<T> Dynamic<Bound<__, __, __, __, __, __>> for T

Source§

impl<T: Clone + Debug> Dynamic<Bound<__, __, __, Clone, __, Debug>> for T

Source§

impl<T: Clone + Unpin + Debug> Dynamic<Bound<__, __, __, Clone, Unpin, Debug>> for T

Source§

impl<T: Clone + Unpin> Dynamic<Bound<__, __, __, Clone, Unpin, __>> for T

Source§

impl<T: Clone> Dynamic<Bound<__, __, __, Clone, __, __>> for T

Source§

impl<T: Debug> Dynamic<Bound<__, __, __, __, __, Debug>> for T

Source§

impl<T: Copy + Clone + Debug> Dynamic<Bound<__, __, Copy, Clone, __, Debug>> for T

Source§

impl<T: Copy + Clone + Unpin + Debug> Dynamic<Bound<__, __, Copy, Clone, Unpin, Debug>> for T

Source§

impl<T: Copy + Clone + Unpin> Dynamic<Bound<__, __, Copy, Clone, Unpin, __>> for T

Source§

impl<T: Copy + Clone> Dynamic<Bound<__, __, Copy, Clone, __, __>> for T

Source§

impl<T: Copy + Debug> Dynamic<Bound<__, __, Copy, __, __, Debug>> for T

Source§

impl<T: Copy + Unpin + Debug> Dynamic<Bound<__, __, Copy, __, Unpin, Debug>> for T

Source§

impl<T: Copy + Unpin> Dynamic<Bound<__, __, Copy, __, Unpin, __>> for T

Source§

impl<T: Copy> Dynamic<Bound<__, __, Copy, __, __, __>> for T

Source§

impl<T: Send + Clone + Debug> Dynamic<Bound<Send, __, __, Clone, __, Debug>> for T

Source§

impl<T: Send + Clone + Unpin + Debug> Dynamic<Bound<Send, __, __, Clone, Unpin, Debug>> for T

Source§

impl<T: Send + Clone + Unpin> Dynamic<Bound<Send, __, __, Clone, Unpin, __>> for T

Source§

impl<T: Send + Clone> Dynamic<Bound<Send, __, __, Clone, __, __>> for T

Source§

impl<T: Send + Debug> Dynamic<Bound<Send, __, __, __, __, Debug>> for T

Source§

impl<T: Send + Copy + Clone + Debug> Dynamic<Bound<Send, __, Copy, Clone, __, Debug>> for T

Source§

impl<T: Send + Copy + Clone + Unpin + Debug> Dynamic<Bound<Send, __, Copy, Clone, Unpin, Debug>> for T

Source§

impl<T: Send + Copy + Clone + Unpin> Dynamic<Bound<Send, __, Copy, Clone, Unpin, __>> for T

Source§

impl<T: Send + Copy + Clone> Dynamic<Bound<Send, __, Copy, Clone, __, __>> for T

Source§

impl<T: Send + Copy + Debug> Dynamic<Bound<Send, __, Copy, __, __, Debug>> for T

Source§

impl<T: Send + Copy + Unpin + Debug> Dynamic<Bound<Send, __, Copy, __, Unpin, Debug>> for T

Source§

impl<T: Send + Copy + Unpin> Dynamic<Bound<Send, __, Copy, __, Unpin, __>> for T

Source§

impl<T: Send + Copy> Dynamic<Bound<Send, __, Copy, __, __, __>> for T

Source§

impl<T: Send + Sync + Clone + Debug> Dynamic<Bound<Send, Sync, __, Clone, __, Debug>> for T

Source§

impl<T: Send + Sync + Clone + Unpin + Debug> Dynamic<Bound<Send, Sync, __, Clone, Unpin, Debug>> for T

Source§

impl<T: Send + Sync + Clone + Unpin> Dynamic<Bound<Send, Sync, __, Clone, Unpin, __>> for T

Source§

impl<T: Send + Sync + Clone> Dynamic<Bound<Send, Sync, __, Clone, __, __>> for T

Source§

impl<T: Send + Sync + Debug> Dynamic<Bound<Send, Sync, __, __, __, Debug>> for T

Source§

impl<T: Send + Sync + Copy + Clone + Debug> Dynamic<Bound<Send, Sync, Copy, Clone, __, Debug>> for T

Source§

impl<T: Send + Sync + Copy + Clone + Unpin + Debug> Dynamic<Bound<Send, Sync, Copy, Clone, Unpin, Debug>> for T

Source§

impl<T: Send + Sync + Copy + Clone + Unpin> Dynamic<Bound<Send, Sync, Copy, Clone, Unpin, __>> for T

Source§

impl<T: Send + Sync + Copy + Clone> Dynamic<Bound<Send, Sync, Copy, Clone, __, __>> for T

Source§

impl<T: Send + Sync + Copy + Debug> Dynamic<Bound<Send, Sync, Copy, __, __, Debug>> for T

Source§

impl<T: Send + Sync + Copy + Unpin + Debug> Dynamic<Bound<Send, Sync, Copy, __, Unpin, Debug>> for T

Source§

impl<T: Send + Sync + Copy + Unpin> Dynamic<Bound<Send, Sync, Copy, __, Unpin, __>> for T

Source§

impl<T: Send + Sync + Copy> Dynamic<Bound<Send, Sync, Copy, __, __, __>> for T

Source§

impl<T: Send + Sync + Unpin + Debug> Dynamic<Bound<Send, Sync, __, __, Unpin, Debug>> for T

Source§

impl<T: Send + Sync + Unpin> Dynamic<Bound<Send, Sync, __, __, Unpin, __>> for T

Source§

impl<T: Send + Sync> Dynamic<Bound<Send, Sync, __, __, __, __>> for T

Source§

impl<T: Send + Unpin + Debug> Dynamic<Bound<Send, __, __, __, Unpin, Debug>> for T

Source§

impl<T: Send + Unpin> Dynamic<Bound<Send, __, __, __, Unpin, __>> for T

Source§

impl<T: Send> Dynamic<Bound<Send, __, __, __, __, __>> for T

Source§

impl<T: Sync + Clone + Debug> Dynamic<Bound<__, Sync, __, Clone, __, Debug>> for T

Source§

impl<T: Sync + Clone + Unpin + Debug> Dynamic<Bound<__, Sync, __, Clone, Unpin, Debug>> for T

Source§

impl<T: Sync + Clone + Unpin> Dynamic<Bound<__, Sync, __, Clone, Unpin, __>> for T

Source§

impl<T: Sync + Clone> Dynamic<Bound<__, Sync, __, Clone, __, __>> for T

Source§

impl<T: Sync + Debug> Dynamic<Bound<__, Sync, __, __, __, Debug>> for T

Source§

impl<T: Sync + Copy + Clone + Debug> Dynamic<Bound<__, Sync, Copy, Clone, __, Debug>> for T

Source§

impl<T: Sync + Copy + Clone + Unpin + Debug> Dynamic<Bound<__, Sync, Copy, Clone, Unpin, Debug>> for T

Source§

impl<T: Sync + Copy + Clone + Unpin> Dynamic<Bound<__, Sync, Copy, Clone, Unpin, __>> for T

Source§

impl<T: Sync + Copy + Clone> Dynamic<Bound<__, Sync, Copy, Clone, __, __>> for T

Source§

impl<T: Sync + Copy + Debug> Dynamic<Bound<__, Sync, Copy, __, __, Debug>> for T

Source§

impl<T: Sync + Copy + Unpin + Debug> Dynamic<Bound<__, Sync, Copy, __, Unpin, Debug>> for T

Source§

impl<T: Sync + Copy + Unpin> Dynamic<Bound<__, Sync, Copy, __, Unpin, __>> for T

Source§

impl<T: Sync + Copy> Dynamic<Bound<__, Sync, Copy, __, __, __>> for T

Source§

impl<T: Sync + Unpin + Debug> Dynamic<Bound<__, Sync, __, __, Unpin, Debug>> for T

Source§

impl<T: Sync + Unpin> Dynamic<Bound<__, Sync, __, __, Unpin, __>> for T

Source§

impl<T: Sync> Dynamic<Bound<__, Sync, __, __, __, __>> for T

Source§

impl<T: Unpin + Debug> Dynamic<Bound<__, __, __, __, Unpin, Debug>> for T

Source§

impl<T: Unpin> Dynamic<Bound<__, __, __, __, Unpin, __>> for T