pub struct StaticLinkedListBackingArray<'buf, T> where
T: Clear, { /* fields omitted */ }
The backing array for the singly-linked lists. This struct needs to be initialized first
before lists can be created.
Convenience function calculating the bytes required for an array of n
elements of type T
plus the list's metadata (i.e. next
pointer). Requires the const_fn
feature.
use static_linkedlist::{Clear, StaticLinkedListBackingArray};
struct U32Clear(pub u32);
impl Clear for U32Clear {
fn clear(&mut self) {
self.0 = 0;
}
}
const BUF_SIZE: usize = StaticLinkedListBackingArray::<U32Clear>::capacity_for(20);
let mut buf: [u8; BUF_SIZE] = [0; BUF_SIZE];
let mut array = StaticLinkedListBackingArray::<U32Clear>::new(&mut buf).unwrap();
Creates a new backing array for linked lists from the given buf
.
The second argument bytes
must be the size of buf
in bytes!
Note that the linked list needs some space for metadata (pointers to the next element).
Consequently, for n
elements of size s
, it does not suffice to allocate s * n
bytes!
To allocate the exact needed amount of memory, use capacity_for()
.
Returns the backing array's capacity.
Returns the remaining space for element sof type T in the array.
Returns true
if the array is full.
Return the number of lists backed by this array.
🔬 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
)
🔬 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
Mutably 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