pub struct Buffer<T: NativeType> { /* fields omitted */ }
Expand description
Buffer
is a contiguous memory region that can
be shared across thread boundaries.
The easiest way to think about Buffer<T>
is being equivalent to
an immutable Vec<T>
, with the following differences:
T
must be NativeType
- clone is
O(1)
- memory is sharable across thread boundaries (it is under an
Arc
)
- it supports external allocated memory (FFI)
Creates a new Buffer
filled with zeros.
This is supported on non-crate feature cache_aligned
only.
Takes ownership of Vec
.
This function is O(1)
Returns the number of bytes in the buffer
Returns whether the buffer is empty.
Returns the byte slice stored in this buffer
Returns a new Buffer that is a slice of this buffer starting at offset
.
Doing so allows the same memory region to be shared between buffers.
Panics iff offset
is larger than len
.
Returns a new Buffer that is a slice of this buffer starting at offset
.
Doing so allows the same memory region to be shared between buffers.
The caller must ensure offset + length <= self.len()
Returns a pointer to the start of this buffer.
Creates a Buffer
from an Iterator
with a trusted length.
Prefer this to collect
whenever possible, as it often enables auto-vectorization.
let v = vec![1u32];
let iter = v.iter().map(|x| x * 2);
let buffer = unsafe { Buffer::from_trusted_len_iter(iter) };
assert_eq!(buffer.len(), 1)
This method assumes that the iterator’s size is correct and is undefined behavior
to use it on an iterator that reports an incorrect length.
Creates a Buffer
from an Iterator
with a trusted (upper) length.
This method assumes that the iterator’s size is correct and is undefined behavior
to use it on an iterator that reports an incorrect length.
This method assumes that the iterator’s size is correct and is undefined behavior
to use it on an iterator that reports an incorrect length.
Performs copy-assignment from source
. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
The resulting type after dereferencing.
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
impl<T> Any for T where
T: 'static + ?Sized,
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
impl<T, U> Into<U> for T where
U: From<T>,
The resulting type after obtaining ownership.
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
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.
impl<V, T> VZip<V> for T where
V: MultiLane<T>,