[][src]Struct sixtyfps_corelib::slice::Slice

#[repr(C)]pub struct Slice<'a, T> { /* fields omitted */ }

That's basicaly 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

impl<'a, T> Slice<'a, T>[src]

pub fn as_slice(self) -> &'a [T][src]

Return a slice

pub fn from_slice(x: &'a [T]) -> Self[src]

Create from a native slice

Trait Implementations

impl<'a, T> Clone for Slice<'a, T>[src]

impl<'a, T> Copy for Slice<'a, T>[src]

impl<'a, T: Debug> Debug for Slice<'a, T>[src]

impl<'a, T> Deref for Slice<'a, T>[src]

type Target = [T]

The resulting type after dereferencing.

impl<'a, T> From<&'a [T]> for Slice<'a, T>[src]

impl<'a, T: PartialEq> PartialEq<Slice<'a, T>> for Slice<'a, T>[src]

impl<'a, T> StructuralPartialEq for Slice<'a, T>[src]

Auto Trait Implementations

impl<'a, T> RefUnwindSafe for Slice<'a, T> where
    T: RefUnwindSafe

impl<'a, T> !Send for Slice<'a, T>

impl<'a, T> !Sync for Slice<'a, T>

impl<'a, T> Unpin for Slice<'a, T>

impl<'a, T> UnwindSafe for Slice<'a, T> where
    T: RefUnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.