Struct sixtyfps_corelib::slice::Slice [−][src]
#[repr(C)]pub struct Slice<'a, T> { /* fields omitted */ }
Expand description
That’s basically the same as &'a [T]
but repr(C)
Can be constructed from a slice using the from trait.
use sixtyfps_corelib::slice::Slice;
let x = Slice::from_slice(&[1, 2, 3]);
assert_eq!(x.len(), 3);
assert_eq!(x[1], 2);
let slice : &'static [u32] = x.as_slice();
Comparing two Slice compare their pointer, not the content.
use sixtyfps_corelib::slice::Slice;
let a = Slice::from_slice(&[1, 2, 3]);
let slice = [1, 2, 3, 4];
let b = Slice::from(&slice[..3]);
// two slice coming from the same pointer are equal.
assert_eq!(b, Slice::from(&slice[..3]));
// these are different because the pointers are different
assert_ne!(a, b);
// use as_slice to compare the contents
assert_eq!(a.as_slice(), b.as_slice());
Implementations
Trait Implementations
Auto Trait Implementations
impl<'a, T> RefUnwindSafe for Slice<'a, T> where
T: RefUnwindSafe,
impl<'a, T> UnwindSafe for Slice<'a, T> where
T: RefUnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more