[][src]Struct abi_stable::std_types::static_str::StaticStr

#[repr(C)]
pub struct StaticStr { /* fields omitted */ }

Wrapper type around &'static str as a workaround for the non-stable-constness of str::len.

Example

use abi_stable::std_types::StaticStr;

const STR:StaticStr=StaticStr::new("foo");

assert_eq!(&STR[..], "foo");

Methods

impl StaticStr[src]

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

Creates a StaticStr from a &'static str

Example

use abi_stable::std_types::StaticStr;

const BAR:StaticStr=StaticStr::new("bar");

assert_eq!(&*BAR, "bar");

pub fn as_str(&self) -> &'static str[src]

Gets the &'static str back.

Example

use abi_stable::std_types::StaticStr;

const NOM:StaticStr=StaticStr::new("baz");

assert_eq!(NOM.as_str(), "baz");

pub fn as_rstr(&self) -> RStr<'static>[src]

Converts the internal &'static str into a RStr<'static>.

Example

use abi_stable::std_types::{RStr,StaticStr};

const PARSEC:StaticStr=StaticStr::new("{}");

assert_eq!(PARSEC.as_rstr(), RStr::from("{}"));

Trait Implementations

impl GetStaticEquivalent_ for StaticStr[src]

type StaticEquivalent = _static_StaticStr

impl SharedStableAbi for StaticStr[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 AsRef<str> for StaticStr[src]

impl AsRef<[u8]> for StaticStr[src]

impl Clone for StaticStr[src]

impl Copy for StaticStr[src]

impl Eq for StaticStr[src]

impl Ord for StaticStr[src]

impl PartialEq<StaticStr> for StaticStr[src]

impl PartialOrd<StaticStr> for StaticStr[src]

impl Display for StaticStr[src]

impl Debug for StaticStr[src]

impl Deref for StaticStr[src]

type Target = str

The resulting type after dereferencing.

impl Hash for StaticStr[src]

impl Borrow<str> for StaticStr[src]

Auto Trait Implementations

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> ToString for T where
    T: Display + ?Sized
[src]

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> StringExt for T where
    T: Borrow<str> + ?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.