Ox

Enum Ox 

Source
pub enum Ox<'a> {
    Owned(OxMut<'a>),
    Borrowed(OxRef<'a>),
}
Expand description

Type-erased value with ownership tracking — like Cow but for any shape.

Variants§

§

Owned(OxMut<'a>)

We own this value and must drop it.

§

Borrowed(OxRef<'a>)

We’re borrowing this value; someone else drops it.

Implementations§

Source§

impl Ox<'static>

Source

pub fn from_boxed<T>(boxed: Box<T>, shape: &'static Shape) -> Self

Take ownership of a boxed value.

Source

pub fn from_value<T>(value: T, shape: &'static Shape) -> Self

Take ownership of a value by boxing it.

Source

pub fn new<T: Facet<'static>>(value: T) -> Self

Take ownership of a value, getting its shape from the Facet trait.

Source§

impl<'a> Ox<'a>

Source

pub fn as_ref(&self) -> OxRef<'_>

Get an immutable view of the value.

Source

pub fn as_mut(&mut self) -> Option<OxMut<'_>>

Get a mutable view of the value (only if owned).

Source

pub fn ptr_const(&self) -> PtrConst

For read-only vtable operations.

Source

pub fn ptr_mut(&mut self) -> Option<PtrMut>

For mutating vtable operations (only if owned).

Source

pub fn shape(&self) -> &'static Shape

Get the shape.

Source

pub unsafe fn get_as<T: 'static>( &self, expected_shape: &'static Shape, ) -> Option<&T>

Get a typed reference if the shape matches.

§Safety

The caller must ensure that T is the correct type for expected_shape.

Trait Implementations§

Source§

impl Debug for Ox<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Ox<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for Ox<'_>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Hash for Ox<'_>

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Ox<'_>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Ox<'_>

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Ox<'a>

§

impl<'a> RefUnwindSafe for Ox<'a>

§

impl<'a> !Send for Ox<'a>

§

impl<'a> !Sync for Ox<'a>

§

impl<'a> Unpin for Ox<'a>

§

impl<'a> !UnwindSafe for Ox<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.