pub trait StringLike<S>: Sizedwhere
S: StringToFromBytes + ?Sized,{
Show 20 methods
// 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 as_os_str(&self) -> &OsStr
where S: AsRef<OsStr> { ... }
fn as_path(&self) -> &Path
where S: AsRef<Path> { ... }
fn as_c_str(&self) -> &CStr
where S: AsRef<CStr> { ... }
fn into_string(self) -> String
where <S as ToOwned>::Owned: Into<String> + From<Box<S>> { ... }
fn into_os_string(self) -> OsString
where <S as ToOwned>::Owned: Into<OsString> + From<Box<S>> { ... }
fn into_path_buf(self) -> PathBuf
where <S as ToOwned>::Owned: Into<PathBuf> + From<Box<S>> { ... }
fn into_c_string(self) -> CString
where <S as ToOwned>::Owned: Into<CString> + From<Box<S>> { ... }
fn into_vec_bytes(self) -> Vec<u8> ⓘ
where <S as ToOwned>::Owned: Into<Vec<u8>> + From<Box<S>> { ... }
fn to_string(&self) -> String
where <S as ToOwned>::Owned: Into<String> { ... }
fn to_os_string(&self) -> OsString
where <S as ToOwned>::Owned: Into<OsString> { ... }
fn to_path_buf(&self) -> PathBuf
where <S as ToOwned>::Owned: Into<PathBuf> { ... }
fn to_c_string(&self) -> CString
where <S as ToOwned>::Owned: Into<CString> { ... }
fn to_vec_bytes(&self) -> Vec<u8> ⓘ
where <S as ToOwned>::Owned: Into<Vec<u8>> { ... }
}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 as_os_str(&self) -> &OsStr
Available on crate features std and osstr only.
fn as_os_str(&self) -> &OsStr
std and osstr only.Borrow the string as an &OsStr
Sourcefn as_path(&self) -> &Path
Available on crate features std and path only.
fn as_path(&self) -> &Path
std and path only.Borrow the string as a &Path
Sourcefn into_string(self) -> String
fn into_string(self) -> String
Consume a string and convert it to a String
Sourcefn into_os_string(self) -> OsString
Available on crate features std and osstr only.
fn into_os_string(self) -> OsString
std and osstr only.Consume a string and convert it to an OsString
Sourcefn into_path_buf(self) -> PathBuf
Available on crate features std and path only.
fn into_path_buf(self) -> PathBuf
std and path only.Consume a string and convert it to a PathBuf
Sourcefn into_c_string(self) -> CString
Available on crate feature cstr only.
fn into_c_string(self) -> CString
cstr only.Consume a string and convert it to a CString
Sourcefn into_vec_bytes(self) -> Vec<u8> ⓘ
Available on crate feature bytes only.
fn into_vec_bytes(self) -> Vec<u8> ⓘ
bytes only.Consume a string and convert it to a Vec<u8>
Sourcefn to_os_string(&self) -> OsString
Available on crate features std and osstr only.
fn to_os_string(&self) -> OsString
std and osstr only.Convert a string reference to an OsString
Sourcefn to_path_buf(&self) -> PathBuf
Available on crate features std and path only.
fn to_path_buf(&self) -> PathBuf
std and path only.Convert a string reference to a PathBuf
Sourcefn to_c_string(&self) -> CString
Available on crate feature cstr only.
fn to_c_string(&self) -> CString
cstr only.Convert a string reference to a CString
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.