pub trait HasBounds<T: 'static>: Bounds {
    // Required methods
    fn cast_box(this: Box<T>) -> Box<Self::Container>;
    fn as_ref(this: &T) -> &Self::Container;
    fn as_mut(this: &mut T) -> &mut Self::Container;
    fn cast_key_box(this: Box<T>) -> Box<Self::KeyContainer>
       where T: 'static + Sized + Hash + Eq;

    // Provided methods
    fn box_key(this: T) -> Box<Self::KeyContainer>
       where T: 'static + Sized + Hash + Eq { ... }
    fn box_value(this: T) -> Box<Self::Container>
       where Self: Sized { ... }
    fn downcast_ref(this: &Self::Container) -> Option<&T>
       where Self: 'static + Sized { ... }
    fn downcast_mut(this: &mut Self::Container) -> Option<&mut T>
       where Self: 'static + Sized { ... }
    fn downcast_box(
        this: Box<Self::Container>
    ) -> Result<Box<T>, Box<Self::Container>>
       where Self: 'static + Sized { ... }
}
Expand description

Trait that marks that specific type fulfill specified bounds. For example HasBounds<CloneBounds> is implemented for all types that are implement Clone & Any.

Required Methods§

source

fn cast_box(this: Box<T>) -> Box<Self::Container>

Converts from Box<T> to Box<Container>

source

fn as_ref(this: &T) -> &Self::Container

Converts from &T to &Container

source

fn as_mut(this: &mut T) -> &mut Self::Container

Converts from &mut T to &mut Container

source

fn cast_key_box(this: Box<T>) -> Box<Self::KeyContainer>
where T: 'static + Sized + Hash + Eq,

Converts from Box<T> to Box<KeyContainer>

Provided Methods§

source

fn box_key(this: T) -> Box<Self::KeyContainer>
where T: 'static + Sized + Hash + Eq,

Boxes key of type T as Box<KeyContainer>

source

fn box_value(this: T) -> Box<Self::Container>
where Self: Sized,

Boxes value of type T as Box<Container>

source

fn downcast_ref(this: &Self::Container) -> Option<&T>
where Self: 'static + Sized,

Attempts to downcast &Container to &T

source

fn downcast_mut(this: &mut Self::Container) -> Option<&mut T>
where Self: 'static + Sized,

Attempts to downcast &mut Container to &mut T

source

fn downcast_box( this: Box<Self::Container> ) -> Result<Box<T>, Box<Self::Container>>
where Self: 'static + Sized,

Attempts to downcast Box<Container> to Box<T>

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<T: 'static + Send + Sync> HasBounds<T> for SyncAnyBounds

source§

impl<T: 'static> HasBounds<T> for AnyBounds

source§

impl<T: CloneAny + Any + Send + Sync> HasBounds<T> for SyncCloneBounds

source§

impl<T: CloneAny + Any> HasBounds<T> for CloneBounds