pub struct PascalStr { /* private fields */ }Expand description
A borrowed slice from a PascalString. Does not own its data.
Implementations§
Source§impl PascalStr
impl PascalStr
Sourcepub fn as_mut_ptr(&mut self) -> *mut AsciiChar
pub fn as_mut_ptr(&mut self) -> *mut AsciiChar
Get a mutable pointer to the first byte of the string buffer.
Sourcepub fn as_cstr(&self) -> Result<Cow<'_, CStr>, InteriorNullError>
pub fn as_cstr(&self) -> Result<Cow<'_, CStr>, InteriorNullError>
Get this string as a CStr.
Returns Err(InteriorNullError) if the string contains any interior nulls. If this string is full,
then a new CString will be allocated to hold the trailing null byte.
Sourcepub fn is_full(&self) -> bool
pub fn is_full(&self) -> bool
Returns true if the string has a length of 255.
When this value is true, no more elements can be pushed onto the string.
Sourcepub fn chars<'a>(&'a self) -> Chars<'a> ⓘ
pub fn chars<'a>(&'a self) -> Chars<'a> ⓘ
Get an immutable iterator to the internal character array.
Sourcepub fn chars_mut<'a>(&'a mut self) -> CharsMut<'a> ⓘ
pub fn chars_mut<'a>(&'a mut self) -> CharsMut<'a> ⓘ
Get a mutable iterator to the internal character array.
Sourcepub fn lines(&self) -> Lines<'_> ⓘ
pub fn lines(&self) -> Lines<'_> ⓘ
Get an iterator over the lines of the internal character array.
Sourcepub fn get_unchecked(&self, index: usize) -> AsciiChar
pub fn get_unchecked(&self, index: usize) -> AsciiChar
Get a character in the string, without checking if the index is within the bounds of len().
This method cannot cause memory unsafety because index is bounds checked within the maximum possible
length of the PascalStr, which means that it cannot read uninitialised memory. However, it can give access
to stale characters if index is greater than or equal to self.len() or isize::MAX, and self.is_full()
is false.
§Panics
This method will panic if index is larger than u8::MAX(255).