[][src]Struct thin_str::ThinStr

#[repr(transparent)]
pub struct ThinStr(_);

Like a Box, but only a single pointer.

use thin_str::ThinStr;
let s = ThinStr::new("abcde");
assert_eq!(s.len(), 5);
let t: ThinStr = "foo".into();
assert_ne!(t, s);
let q = s.clone();
assert_eq!(s, q);

Methods

impl ThinStr[src]

pub const fn empty() -> Self[src]

Create a new empty string.

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

Create a new string with the same contents as s.

pub fn new_zeroed(len: usize) -> Self[src]

Create a new string with all bytes initialized to zero.

pub fn len(&self) -> usize[src]

How long is the string, in bytes.

pub fn is_empty(&self) -> bool[src]

Returns true if the len is zero.

pub fn to_string(&self) -> String[src]

We can't specialize the real to_string, but at least we can help out people whose muscle memory for -> String is 'call to_string()'

pub fn as_bytes(&self) -> &[u8][src]

Access the string's byte array.

pub unsafe fn as_mut_bytes(&mut self) -> &mut [u8][src]

Get the underlying byte array mutably. It's unsound to write into this unless you ensure that it remains valid UTF8 after your writes.

Safety

Caller must not write non-utf8 bytes

pub fn as_mut_str(&mut self) -> &mut str[src]

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

Trait Implementations

impl AsMut<str> for ThinStr[src]

impl AsRef<str> for ThinStr[src]

impl Borrow<str> for ThinStr[src]

impl Clone for ThinStr[src]

impl Debug for ThinStr[src]

impl Default for ThinStr[src]

impl Deref for ThinStr[src]

type Target = str

The resulting type after dereferencing.

impl DerefMut for ThinStr[src]

impl Display for ThinStr[src]

impl Drop for ThinStr[src]

impl Eq for ThinStr[src]

impl<'_> From<&'_ str> for ThinStr[src]

impl From<String> for ThinStr[src]

impl FromStr for ThinStr[src]

type Err = Infallible

The associated error which can be returned from parsing.

impl Hash for ThinStr[src]

impl Index<Range<usize>> for ThinStr[src]

type Output = str

The returned type after indexing.

impl Index<RangeFrom<usize>> for ThinStr[src]

type Output = str

The returned type after indexing.

impl Index<RangeFull> for ThinStr[src]

type Output = str

The returned type after indexing.

impl Index<RangeInclusive<usize>> for ThinStr[src]

type Output = str

The returned type after indexing.

impl Index<RangeTo<usize>> for ThinStr[src]

type Output = str

The returned type after indexing.

impl Index<RangeToInclusive<usize>> for ThinStr[src]

type Output = str

The returned type after indexing.

impl IndexMut<Range<usize>> for ThinStr[src]

impl IndexMut<RangeFrom<usize>> for ThinStr[src]

impl IndexMut<RangeFull> for ThinStr[src]

impl IndexMut<RangeInclusive<usize>> for ThinStr[src]

impl IndexMut<RangeTo<usize>> for ThinStr[src]

impl IndexMut<RangeToInclusive<usize>> for ThinStr[src]

impl Ord for ThinStr[src]

impl<'a, 'b> PartialEq<&'a ThinStr> for str[src]

impl<'a, 'b> PartialEq<&'a str> for ThinStr[src]

impl PartialEq<ThinStr> for ThinStr[src]

impl<'a, 'b> PartialEq<ThinStr> for str[src]

impl<'a, 'b> PartialEq<ThinStr> for &'a str[src]

impl<'a, 'b> PartialEq<str> for ThinStr[src]

impl<'a, 'b> PartialEq<str> for &'a ThinStr[src]

impl PartialOrd<ThinStr> for ThinStr[src]

impl Send for ThinStr[src]

impl Sync for ThinStr[src]

Auto Trait Implementations

impl Unpin for ThinStr

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> 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.