[−][src]Trait futures_intrusive::buffer::RealArray
A marker trait which may only be implemented for native array types, like
[T; 2]
. The library incorporates several components that are parameterized
by array types, but currently Rust provides no safe mechanism to express
that.
In order to work around the limitations, these methods only accept arrays
which implement the RealArray
type. The library provides an implementation
of RealArray
for arrays up to length 64, as well as for all powers of 2
up to 64k.
In order to let the library accept arrays of bigger sizes, RealArray
can
be implemented by users via newtypes. A type as defined in the following
example can be passed to the library:
use futures_intrusive::buffer::RealArray; use futures_intrusive::channel::LocalChannel; struct I32x384Array([i32; 384]); unsafe impl RealArray<i32> for I32x384Array { const LEN: usize = 384; } impl AsMut<[i32]> for I32x384Array { fn as_mut(&mut self) -> &mut [i32] { &mut self.0 } } impl AsRef<[i32]> for I32x384Array { fn as_ref(&self) -> &[i32] { &self.0 } } fn main() { let channel = LocalChannel::<i32, I32x384Array>::new(); }