pub unsafe trait Str {
const CONTAINS_NUL: bool;
// Required methods
unsafe fn from_bytes_unchecked(bytes: &[u8]) -> &Self;
fn as_bytes(&self) -> &[u8] ⓘ;
}Expand description
Represents str-like types that could be cast to valid byte patterns and back.
§Safety
It is the implementor’s responsibility to ensure that the bytes returned by as_bytes could be safely passed to from_bytes_unchecked.
Required Associated Constants§
Sourceconst CONTAINS_NUL: bool
const CONTAINS_NUL: bool
Indicates whether the bytes returned by as_bytes contain a NUL byte.
Required Methods§
Sourceunsafe fn from_bytes_unchecked(bytes: &[u8]) -> &Self
unsafe fn from_bytes_unchecked(bytes: &[u8]) -> &Self
Casts the given bytes to a reference to Self.
§Safety
The bytes must be valid byte patterns for Self.
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.