Crates.io | membuf |
lib.rs | membuf |
version | 0.0.5 |
source | src |
created_at | 2015-05-06 08:42:51.306208 |
updated_at | 2015-12-11 23:54:10.497015 |
description | A safe-ish wrapper for allocating and reallocating heap buffers. |
homepage | |
repository | https://github.com/reem/rust-membuf.git |
max_upload_size | |
id | 2040 |
size | 15,787 |
A safe-ish wrapper for allocating, reallocating and deallocating heap buffers.
A safe wrapper around a heap allocated buffer of Ts, tracking capacity only.
MemBuf makes no promises about the actual contents of this memory, that's up
to the user of the structure and can be manipulated using the standard pointer
utilities, accessible through the impl of Deref<Target=*mut T>
for MemBuf<T>
.
You can think of MemBuf<T>
as an approximation for Box<[T]>
where the elements
are not guaranteed to be valid/initialized. It is meant to be used as a building
block for other collections, so they do not have to concern themselves with the
minutiae of allocating, reallocating, and deallocating memory.
However, note that MemBuf<T>
does not have a destructor, and implements Copy
,
as a result, it does not implement Send
or Sync
, and it is the responsibility
of the user to call deallocate
if they wish to free memory.
There is also a UniqueBuf<T>
which does not implement Copy
, implements
Send
and Sync
, and has a destructor responsible for deallocation.
Use the crates.io repository; add this to your Cargo.toml
along
with the rest of your dependencies:
[dependencies]
membuf = "*"
Jonathan Reem is the primary author and maintainer of membuf.
MIT