Skip to main content

ObjectOrVariant

Trait ObjectOrVariant 

Source
pub trait ObjectOrVariant<T> {
    // Required methods
    fn convert_to_dest_type(object: &T) -> Option<&Self>;
    fn convert_to_dest_type_mut(object: &mut T) -> Option<&mut Self>;
}
Expand description

This trait unifies pool objects and their variants.

If T is the pool object type, ObjectOrVariant::convert_to_dest_type returns the pool object itself.

If T is a variant of the pool object type, ObjectOrVariant::convert_to_dest_type returns the variant of the pool object.

The Pool struct uses this trait to unify the logic of retrieving both pool objects and their variants.

Required Methods§

Source

fn convert_to_dest_type(object: &T) -> Option<&Self>

Source

fn convert_to_dest_type_mut(object: &mut T) -> Option<&mut Self>

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, U> ObjectOrVariant<T> for U