pub struct Miny<T: ?Sized> { /* private fields */ }Expand description
Box<T> but with small data stored inline
See the crate docs for more
Implementations§
Source§impl<T: ?Sized + Any> Miny<T>
Extra implementations for Box<dyn Any>-like behavior
impl<T: ?Sized + Any> Miny<T>
Extra implementations for Box<dyn Any>-like behavior
Sourcepub unsafe fn downcast_ref_unchecked<V: Any>(&self) -> &V
pub unsafe fn downcast_ref_unchecked<V: Any>(&self) -> &V
Returns a reference to the inner value
§Safety
The contained value must be of type T. Calling this method
with the incorrect type is undefined behavior.
Sourcepub unsafe fn downcast_mut_unchecked<V: Any>(&mut self) -> &mut V
pub unsafe fn downcast_mut_unchecked<V: Any>(&mut self) -> &mut V
Returns a mutable reference to the inner value
§Safety
The contained value must be of type T. Calling this method
with the incorrect type is undefined behavior.
Sourcepub unsafe fn downcast_unchecked<V: Any>(self) -> V
pub unsafe fn downcast_unchecked<V: Any>(self) -> V
Downcasts the value to a concrete type
§Safety
The contained value must be of type T. Calling this method
with the incorrect type is undefined behavior.
Sourcepub fn downcast_ref<V: Any>(&self) -> Option<&V>
pub fn downcast_ref<V: Any>(&self) -> Option<&V>
Returns a reference to the inner value if it is of type T, or None
if it isn’t
Sourcepub fn downcast_mut<V: Any>(&mut self) -> Option<&mut V>
pub fn downcast_mut<V: Any>(&mut self) -> Option<&mut V>
Returns a mutable reference to the inner value if it is of type T, or
None if it isn’t
Source§impl<T> Miny<T>
impl<T> Miny<T>
Sourcepub fn unsize<S: ?Sized>(this: Self) -> Miny<S>where
T: Unsize<S>,
pub fn unsize<S: ?Sized>(this: Self) -> Miny<S>where
T: Unsize<S>,
Attach the appropriate metadata to turn the value into an unsized value
Sourcepub fn new_unsized<S: ?Sized>(value: T) -> Miny<S>where
T: Unsize<S>,
pub fn new_unsized<S: ?Sized>(value: T) -> Miny<S>where
T: Unsize<S>,
Shorthand for Miny::unsize(Miny::new(v)),
or Miny::from(Box::new(v) as S)
Sourcepub fn into_inner(this: Self) -> T
pub fn into_inner(this: Self) -> T
Consume the Miny and take the value out,
equivalent to box’s deref move
Source§impl<T: ?Sized> Miny<T>
impl<T: ?Sized> Miny<T>
Sourcepub fn layout(this: &Self) -> Layout
pub fn layout(this: &Self) -> Layout
Get the layout of the inner value, not really useful for much except for maybe some unsafe things.
Sourcepub fn on_stack(this: &Self) -> bool
pub fn on_stack(this: &Self) -> bool
true if the value is stored inline on the stack instead of with a
heap allocation, not really useful for much except for maybe some unsafe
things or as a diagnostic tool.
Sourcepub fn into_box(this: Self) -> Box<T>
pub fn into_box(this: Self) -> Box<T>
Consume the Miny and take the value out as a Box, as opposed to
into_inner it also works on unsized values.