[][src]Struct abi_stable::std_types::StaticSlice

#[repr(C)]
pub struct StaticSlice<T: 'static> { /* fields omitted */ }

Wrapper type around &'static [T] as a workaround for the non-stable-constness of <[T]>::len.

Once <[T]>::len is stable in const contests define the RSlice::from_slice const fn so as to replace this type with RSlice<'static,T>.

Example

use abi_stable::std_types::StaticSlice;

const SLICE:StaticSlice<u32>=StaticSlice::new(&[11,12,13,14]);

assert_eq!(&SLICE[..], &[11,12,13,14]);

Methods

impl<T: 'static> StaticSlice<T>[src]

pub const fn new(s: &'static [T]) -> Self[src]

Creates a StaticSlice<T> from a &'static [T]

Example

use abi_stable::std_types::StaticSlice;

let slic=StaticSlice::new(&[0,1,2,3]);

assert_eq!(&*slic,&[0,1,2,3]);

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

Gets the &'static [Y] back.

Example

use abi_stable::std_types::StaticSlice;

let slic=StaticSlice::new(&[-1,-2,-3,-4]);

assert_eq!(slic.as_slice(),&[-1,-2,-3,-4]);

Important traits for RSlice<'a, u8>
pub fn as_rslice(&self) -> RSlice<'static, T>[src]

Converts the internal &'static [T] into a RSlice<'static,T>.

Example

use abi_stable::std_types::{RSlice,StaticSlice};

let slic=StaticSlice::new(&[-1,-2,-3,-4]);

assert_eq!(slic.as_rslice(), RSlice::from_slice(&[-1,-2,-3,-4]));

Trait Implementations

impl<T: 'static> GetStaticEquivalent_ for StaticSlice<T> where
    T: __StableAbi
[src]

type StaticEquivalent = _static_StaticSlice<__GetStaticEquivalent<T>>

impl<T: 'static> SharedStableAbi for StaticSlice<T> where
    T: __StableAbi
[src]

type IsNonZeroType = False

Whether this type has a single invalid bit-pattern. Read more

type Kind = __ValueKind

The kind of abi stability of this type,there are 2: Read more

impl<T> AsRef<[T]> for StaticSlice<T>[src]

impl<T> Clone for StaticSlice<T>[src]

impl<T> Copy for StaticSlice<T>[src]

impl<T> Eq for StaticSlice<T> where
    T: Eq
[src]

impl<T> Ord for StaticSlice<T> where
    T: Ord
[src]

impl<T> PartialEq<StaticSlice<T>> for StaticSlice<T> where
    T: PartialEq
[src]

impl<T> PartialOrd<StaticSlice<T>> for StaticSlice<T> where
    T: PartialOrd
[src]

impl<T> Debug for StaticSlice<T> where
    T: Debug
[src]

impl<T> Deref for StaticSlice<T>[src]

type Target = [T]

The resulting type after dereferencing.

impl<T> Hash for StaticSlice<T> where
    T: Hash
[src]

impl<T> Borrow<[T]> for StaticSlice<T>[src]

Auto Trait Implementations

impl<T> Send for StaticSlice<T> where
    T: Send + Sync

impl<T> Sync for StaticSlice<T> where
    T: Sync

impl<T> Unpin for StaticSlice<T> where
    T: Unpin

impl<T> UnwindSafe for StaticSlice<T> where
    T: RefUnwindSafe + UnwindSafe

impl<T> RefUnwindSafe for StaticSlice<T> where
    T: RefUnwindSafe

Blanket Implementations

impl<This> GetConstGenericVTable for This where
    This: StableAbi + Eq + PartialEq<This> + Debug + Send + Sync
[src]

impl<This> StableAbi for This where
    This: SharedStableAbi<Kind = ValueKind>, 
[src]

impl<This> TransmuteElement for This where
    This: ?Sized
[src]

impl<'a, T> BorrowOwned<'a> for T where
    T: 'a + Clone
[src]

type ROwned = T

type RBorrowed = &'a T

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

impl<T> From<T> for 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.

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

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

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

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

type Type = T

The same type as Self. Read more

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

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

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

The error type returned when the conversion fails.