pub struct Growable { /* fields omitted */ }A chunk of the heap memory that can be assigned with an arbitrary type.
First, let's spawn a new Growable. In this case no allocation will be performed.
let growable = Growable::new();
Now we can assign some data to it.
let arr: Reusable<[char; 3]> = growable.consume(['f', 'o', 'o']);
assert_eq!(&*arr, &['f', 'o', 'o']);
No longer wanted data can be then freed on demand, fetching Growable back.
Then it might be assigned with some data again and so on.
let growable = Reusable::free(arr);
let arr: Reusable<[char; 6]> = growable.consume(['f', 'o', 'o', 'b', 'a', 'r']);
assert_eq!(&*arr, &['f', 'o', 'o', 'b', 'a', 'r']);
Returns a new instance of Growable but does not allocate any memory on the heap yet.
Returns a new instance of Growable with memory already allocated on the heap suitable to
store an instance of a given type T.
struct Foo {
a: u8,
b: usize,
c: (),
}
let _ = Growable::with_capacity_for_type::<Foo>();
Returns a new instance of Growable with memory already allocated on the heap.
ptr_alignment is not a power of two.
len overflows after being rounded up to the nearest multiple of the alignment.
Might trigger alloc_error handler.
let _ = Growable::with_capacity(256, 16);
Returns true if no memory has been allocated yet.
Returns the amount of memory allocated by this Growable.
Places an instance of T on the heap, an actual (re)allocation will be performed
only if there is not enough space or the pointer alignment is invalid.
Might trigger alloc_error handler.
let growable = Growable::with_capacity(128, 8);
let num = growable.consume(0usize);
assert_eq!(*num, 0usize);
Returns the "default value" for a type. Read more
Performs copy-assignment from source. Read more
Executes the destructor for this type. Read more
Formats the value using the given formatter. Read more
Formats the value using the given formatter.
Creates owned data from borrowed data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (toowned_clone_into)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (try_from)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from)
Immutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (get_type_id)
this method will likely be replaced by an associated static
🔬 This is a nightly-only experimental API. (try_from)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from)
Mutably borrows from an owned value. Read more