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§

Examples found in repository?
src/traits.rs (line 964)
963
964
965
966
967
968
969
970
971
    fn try_to_string(&self) -> Result<String> {
        self.try_as_str().map(|s| s.to_string())
    }
    /// # Safety
    /// This function is unsafe because it does not check if the bytes are valid UTF-8.
    #[inline]
    fn as_str(&self) -> &str {
        self.try_as_str().unwrap()
    }
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()
    }
Safety

This function is unsafe because it does not check if the bytes are valid UTF-8.

Safety

This function is unsafe because it does not check if the bytes are valid UTF-8.

Examples found in repository?
src/traits.rs (line 996)
992
993
994
995
996
997
    fn into_string(self) -> String
    where
        Self: Sized,
    {
        self.to_string()
    }
Safety

This function is unsafe because it does not check if the bytes are valid UTF-8.

Implementors§

implement AsBytes for impl AsBytes