Struct Box

Source
pub struct Box<'a, T: ?Sized>(/* private fields */);
Expand description

Just a standard Box, more or less. The main difference is that its constructor is fallible instead of panicking.

It probably has fewer features than Rust’s version, but it should be possible to add or emulate those.

Implementations§

Source§

impl<'a, T> Box<'a, T>

Source

pub fn new(value: T) -> Result<Self, T>

Moves value onto the Pebble heap.

§Errors

Iff the heap allocation fails.

Source

pub fn into_inner(box: Self) -> T

Moves r#box’s value off the Pebble heap.

Source§

impl<'a> Box<'a, [MaybeUninit<u8>]>

Source

pub fn new_buffer_uninit(len: usize) -> Result<Self, ()>

§Errors

Iff not enough heap memory could be allocated.

Source

pub fn assume_init(box: Self) -> Box<'a, [u8]>

Source§

impl<'a, T: ?Sized> Box<'a, T>

Source

pub fn leak(box: Self) -> &'a mut T
where T: 'a,

Source

pub unsafe fn from_raw(raw: &'a mut T) -> Self

Reassembles a Box instance from a leaked reference.

§Safety

Iff the reference was previously leaked from a matching Box instance.

Source

pub unsafe fn downcast_unchecked<U: Unsize<T>>(box: Self) -> Box<'a, U>

Reinterprets a Box of an type T into its original sized type Box<U>.

§Safety

Iff this instance was created from a value memory-compatible to U.

Source§

impl Box<'static, CStr<Heap>>

Source

pub fn clone_to_c_str(value: &str) -> Result<Self, ()>

Clones a Rust str onto the Pebble heap, appending '\0' in the process.

§Errors

Iff the heap allocation fails.

Trait Implementations§

Source§

impl<'a, T: ?Sized> Deref for Box<'a, T>

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<'a, T: ?Sized> DerefMut for Box<'a, T>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl<'a, T: ?Sized> Drop for Box<'a, T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<'a> From<Box<'a, CStr<Heap>>> for Box<'a, str>

Source§

fn from(value: Box<'a, CStr<Heap>>) -> Self

Converts to this type from the input type.
Source§

impl<'a, F: ?Sized + Future + Unpin> Future for Box<'a, F>

Source§

type Output = <F as Future>::Output

The type of value produced on completion.
Source§

fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>

Attempts to resolve the future to a final value, registering the current task for wakeup if the value is not yet available. Read more
Source§

impl<'a> TryFrom<Box<'a, str>> for Box<'a, CStr<Heap>>

Source§

type Error = ()

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

fn try_from(value: Box<'_, str>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Box<'a, U>> for Box<'a, T>

Source§

impl<'a, T: ?Sized> Unpin for Box<'a, T>

Auto Trait Implementations§

§

impl<'a, T> Freeze for Box<'a, T>
where T: ?Sized,

§

impl<'a, T> RefUnwindSafe for Box<'a, T>
where T: RefUnwindSafe + ?Sized,

§

impl<'a, T> Send for Box<'a, T>
where T: Send + ?Sized,

§

impl<'a, T> Sync for Box<'a, T>
where T: Sync + ?Sized,

§

impl<'a, T> !UnwindSafe for Box<'a, T>

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<F> IntoFuture for F
where F: Future,

Source§

type Output = <F as Future>::Output

The output that the future will produce on completion.
Source§

type IntoFuture = F

Which kind of future are we turning this into?
Source§

fn into_future(self) -> <F as IntoFuture>::IntoFuture

Creates a future from a value. Read more
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.