pub trait StringLike<S>: Sizedwhere
S: StringToFromBytes + ?Sized,{
// Required methods
fn as_ref_type(&self) -> &S;
fn as_bytes(&self) -> &[u8] ⓘ;
fn into_owned_type(self) -> <S as ToOwned>::Owned
where <S as ToOwned>::Owned: From<Box<S>>;
fn to_owned_type(&self) -> <S as ToOwned>::Owned;
// Provided methods
fn is_empty(&self) -> bool { ... }
fn len(&self) -> usize { ... }
fn as_str(&self) -> &str
where S: AsRef<str> { ... }
fn into_string(self) -> String
where <S as ToOwned>::Owned: Into<String> + From<Box<S>> { ... }
fn to_string(&self) -> String
where <S as ToOwned>::Owned: Into<String> { ... }
}Expand description
Trait for string types that provide various operations
Required Methods§
Sourcefn as_ref_type(&self) -> &S
fn as_ref_type(&self) -> &S
Borrow a string reference as &S
Sourcefn into_owned_type(self) -> <S as ToOwned>::Owned
fn into_owned_type(self) -> <S as ToOwned>::Owned
Consume a string and convert it to an owned string. S::to_owned is called on Borrowed/Inlined/RefCounted variants.
Boxed variants are converted directly into S::Owned (most likely without copy or allocation).
Sourcefn to_owned_type(&self) -> <S as ToOwned>::Owned
fn to_owned_type(&self) -> <S as ToOwned>::Owned
Convert a string reference to an owned string. S::to_owned is called on all variants.
Provided Methods§
Sourcefn into_string(self) -> String
fn into_string(self) -> String
Consume a string and convert it to a String
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.