pub struct Latin1Str { /* private fields */ }
Expand description
A borrowed latin-1 encoded string (like &str
)
Implementations§
Source§impl Latin1Str
impl Latin1Str
Sourcepub const unsafe fn from_bytes_unchecked(text: &[u8]) -> &Self
pub const unsafe fn from_bytes_unchecked(text: &[u8]) -> &Self
Sourcepub fn from_bytes_until_nul(bytes: &[u8]) -> &Self
pub fn from_bytes_until_nul(bytes: &[u8]) -> &Self
Wrap all bytes before the first nul as a Latin1Str
This method will never fail
let s = Latin1Str::from_bytes_until_nul(b"Hello\0World!");
assert_eq!(s.as_bytes(), b"Hello");
let s = Latin1Str::from_bytes_until_nul(b"Hello World!");
assert_eq!(s.as_bytes(), b"Hello World!");
Sourcepub fn new(bytes: &[u8]) -> &Self
👎Deprecated: Use from_bytes_until_nul
instead
pub fn new(bytes: &[u8]) -> &Self
from_bytes_until_nul
insteadAlias of Latin1Str::from_bytes_until_nul
Sourcepub const fn as_bytes(&self) -> &[u8] ⓘ
pub const fn as_bytes(&self) -> &[u8] ⓘ
Get the bytes of the string
let s = Latin1Str::from_bytes_until_nul(b"Hello World!");
assert_eq!(s.as_bytes(), b"Hello World!")
Trait Implementations§
Source§impl Borrow<Latin1Str> for Latin1String
impl Borrow<Latin1Str> for Latin1String
Source§impl From<&Latin1Str> for Latin1String
impl From<&Latin1Str> for Latin1String
Source§fn from(src: &Latin1Str) -> Latin1String
fn from(src: &Latin1Str) -> Latin1String
Converts to this type from the input type.
Source§impl PartialEq<&Latin1Str> for Latin1String
impl PartialEq<&Latin1Str> for Latin1String
Source§impl PartialEq<Latin1Str> for Latin1String
impl PartialEq<Latin1Str> for Latin1String
Source§impl PartialEq<Latin1String> for &Latin1Str
impl PartialEq<Latin1String> for &Latin1Str
Source§impl PartialEq<Latin1String> for Latin1Str
impl PartialEq<Latin1String> for Latin1Str
Source§impl PartialOrd for Latin1Str
impl PartialOrd for Latin1Str
Source§impl ToOwned for Latin1Str
impl ToOwned for Latin1Str
Source§type Owned = Latin1String
type Owned = Latin1String
The resulting type after obtaining ownership.
Source§fn to_owned(&self) -> Self::Owned
fn to_owned(&self) -> Self::Owned
Creates owned data from borrowed data, usually by cloning. Read more
1.63.0 · Source§fn clone_into(&self, target: &mut Self::Owned)
fn clone_into(&self, target: &mut Self::Owned)
Uses borrowed data to replace owned data, usually by cloning. Read more