[−][src]Struct thin_str::ThinStr
Like a Box
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
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]
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for ThinStr
[src]
impl Default for ThinStr
[src]
impl Deref for ThinStr
[src]
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.
fn from_str(s: &str) -> Result<Self, Self::Err>
[src]
impl Hash for ThinStr
[src]
fn hash<H: Hasher>(&self, state: &mut H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl Index<Range<usize>> for ThinStr
[src]
impl Index<RangeFrom<usize>> for ThinStr
[src]
type Output = str
The returned type after indexing.
fn index(&self, idx: RangeFrom<usize>) -> &str
[src]
impl Index<RangeFull> for ThinStr
[src]
impl Index<RangeInclusive<usize>> for ThinStr
[src]
type Output = str
The returned type after indexing.
fn index(&self, idx: RangeInclusive<usize>) -> &str
[src]
impl Index<RangeTo<usize>> for ThinStr
[src]
type Output = str
The returned type after indexing.
fn index(&self, idx: RangeTo<usize>) -> &str
[src]
impl Index<RangeToInclusive<usize>> for ThinStr
[src]
type Output = str
The returned type after indexing.
fn index(&self, idx: RangeToInclusive<usize>) -> &str
[src]
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]
fn index_mut(&mut self, idx: RangeInclusive<usize>) -> &mut str
[src]
impl IndexMut<RangeTo<usize>> for ThinStr
[src]
impl IndexMut<RangeToInclusive<usize>> for ThinStr
[src]
fn index_mut(&mut self, idx: RangeToInclusive<usize>) -> &mut str
[src]
impl Ord for ThinStr
[src]
fn cmp(&self, o: &ThinStr) -> Ordering
[src]
fn max(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
1.21.0[src]
fn clamp(self, min: Self, max: Self) -> Self
[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]
fn partial_cmp(&self, o: &ThinStr) -> Option<Ordering>
[src]
fn lt(&self, o: &ThinStr) -> bool
[src]
fn le(&self, o: &ThinStr) -> bool
[src]
fn gt(&self, o: &ThinStr) -> bool
[src]
fn ge(&self, o: &ThinStr) -> bool
[src]
impl Send for ThinStr
[src]
impl Sync for ThinStr
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,