API reference Dodo 0.1.4

alloc/boxed

Public declarations, types, methods, and source contracts for alloc/boxed.

On this page

Library guide · API index and notation

This page is generated from the bundled library in this checkout. Signatures and adjacent source comments are reproduced below; the linked guide explains usage, storage, failures, and platform support.

import "alloc/boxed"

Names used in signatures

Unqualified names denote this package’s types (including other source files in the same package), language built-ins, or generic parameters such as T. Qualified names use the import aliases below. These aliases belong to the library source; import a dependency yourself to use its alias in your program.

Alias Package Source file
block alloc/block boxed.dodo
error alloc/error boxed.dodo
layout alloc/layout boxed.dodo
mem core/mem boxed.dodo
ptr core/ptr boxed.dodo

Box

Struct · Source

Own one initialized T and an exclusive checked borrow of its allocator. A provides allocate(&mut self, &Layout)->Block!AllocError and an unsafe deallocate(&mut self, Block). Dispatch is static, with no vtable or heap. T must not carry checked borrows or contain Results, including nested ones. mem.init enforces this before ownership enters opaque allocation storage; dropping the Box must never silently discard a Result handling obligation. The allocator remains exclusively borrowed until Box is consumed/dropped.

pub struct Box<T, A> {
    // Private implementation fields omitted.
}

Box.as_ref

Function · Source

Checked views keep this box and its allocator alive. A mutable view excludes replace, into_inner, moving, and destruction until its last use.

pub fn as_ref(&self) -> &T from(self)

Box.as_mut

Function · Source

pub fn as_mut(&mut self) -> &mut T from(self)

Box.get

Function · Source

Synonyms used by the portable owned-container APIs.

pub fn get(&self) -> &T

Box.get_mut

Function · Source

pub fn get_mut(&mut self) -> &mut T

Box.as_ptr

Function · Source

pub fn as_ptr(&self) -> *const T

Box.as_mut_ptr

Function · Source

pub fn as_mut_ptr(&mut self) -> *mut T

Box.replace

Function · Source

Replace the initialized value, returning ownership of the previous one.

pub fn replace(&mut self, value: T) -> T

Box.into_inner

Function · Source

Moves the value out; the destructor still releases the allocation.

pub fn into_inner(self) -> T

new

Function · Source

On failure value is destroyed exactly once. SAFETY: every successful A.allocate must return unique, writable storage of the requested layout that remains valid until A.deallocate. Deallocation must release only that block, and must not access T after it is destroyed. An unconstrained generic allocator cannot express this contract statically.

pub unsafe fn new<T, A>(allocator: &mut A, value: T) -> Box<T, A>!error.AllocError from(allocator)

Requires an unsafe context. Follow the source safety preconditions and the linked guide before calling this API.

Type to search all documentation.

Keyboard shortcuts

Search documentation
Ctrl K or /
Move through results
↑ ↓
Open selected result
Enter
Close a dialog
Esc
Show these shortcuts
?