Expand description
Owned Allocations. A crate to help reducing manual memory management errors.
The idea is to use a type like UninitAlloc
for uninitialized dynamic
allocations. After initializing it, you have a OwnedAlloc
which is pretty
similar to a Box
. However, unlike a Box
, you may move the value out from
the OwnedAlloc
and getting an UninitAlloc
back.
For vec-like structures, a type RawVec
is available, pretty similar to the
one used by the standard library. Currently, no other help is provided for
arrays/vectors.
There is also a type Cache
, which is actually more general than
allocation, but may be useful for allocations. It can save unused
allocations requested on a tight loop.
Structs§
- Alloc
Err - Error returned from the allocator.
- Cache
- A general purpouse cache suitable for saving discarted memory allocations in a tight loop.
- Layout
Err - Error caused by invalid size or alignment.
- Owned
Alloc - Dynamic allocation of a
T
whose memory is considered fully initialized. The allocation and its content are freed ondrop
. Similar to aBox
. If the size of the allocation is zero, no allocation is performed and a dangling pointer is used (just like instd
). For the drop checker, the type acts as if it contains aT
due to usage ofPhantomData<T>
. - RawVec
- Raw Vector allocation. This allocation, instead of holding a pointer to a
single
T
, holds a pointer to as manyT
are required. The allocation is resizable and is freed ondrop
. No initialization or deinitialization of the elements is performed. This type may be useful forVec
-like types. If the size of the allocation is zero, no allocation is performed and a dangling pointer is used (just like instd
). For the drop checker, the type acts as if it contains aT
due to usage ofPhantomData<T>
. - Uninit
Alloc - Dynamic allocation of a
T
whose memory is considered uninitialized. The allocation is freed ondrop
. If the size of the allocation is zero, no allocation is performed and a dangling pointer is used (just like instd
). For the drop checker, the type acts as if it contains aT
due to usage ofPhantomData<T>
.
Enums§
- Maybe
Uninit Alloc - Pointer to memory allocaation that might be either initialized or
uninitialized. For the drop checker, the type acts as if it contains a
T
due to usage ofPhantomData<T>
. - RawVec
Err - Errors returned by the
RawVec
.