Trait stdto_core::ToStringForBytes
source · pub trait ToStringForBytes: AsBytes {
fn try_as_str(&self) -> Result<&str> { ... }
fn try_to_string(&self) -> Result<String> { ... }
fn as_str(&self) -> &str { ... }
fn to_string(&self) -> String { ... }
fn to_string_lossy(&self) -> String { ... }
fn try_into_string(self) -> Result<String>
where
Self: Sized,
{ ... }
fn into_string(self) -> String
where
Self: Sized,
{ ... }
}
Expand description
Provided Methods§
sourcefn try_as_str(&self) -> Result<&str>
fn try_as_str(&self) -> Result<&str>
sourcefn try_to_string(&self) -> Result<String>
fn try_to_string(&self) -> Result<String>
Examples found in repository?
src/traits.rs (line 976)
975 976 977 978 979 980 981 982 983 984 985 986 987 988
fn to_string(&self) -> String {
self.try_to_string().unwrap()
}
#[inline]
fn to_string_lossy(&self) -> String {
String::from_utf8_lossy(self.as_byte_slice()).to_string()
}
#[inline]
fn try_into_string(self) -> Result<String>
where
Self: Sized,
{
self.try_to_string()
}
sourcefn as_str(&self) -> &str
fn as_str(&self) -> &str
Safety
This function is unsafe because it does not check if the bytes are valid UTF-8.
sourcefn to_string(&self) -> String
fn to_string(&self) -> String
Safety
This function is unsafe because it does not check if the bytes are valid UTF-8.
fn to_string_lossy(&self) -> String
fn try_into_string(self) -> Result<String>where
Self: Sized,
sourcefn into_string(self) -> Stringwhere
Self: Sized,
fn into_string(self) -> Stringwhere
Self: Sized,
Safety
This function is unsafe because it does not check if the bytes are valid UTF-8.
Implementors§
impl<T: AsBytes> ToStringForBytes for T
implement AsBytes
for impl AsBytes