Struct PascalStr

Source
pub struct PascalStr { /* private fields */ }
Expand description

A borrowed slice from a PascalString. Does not own its data.

Implementations§

Source§

impl PascalStr

Source

pub fn as_ptr(&self) -> *const AsciiChar

Get a pointer to the first byte of the string buffer.

Source

pub fn as_mut_ptr(&mut self) -> *mut AsciiChar

Get a mutable pointer to the first byte of the string buffer.

Source

pub fn as_str(&self) -> &str

Get the PascalStr as an immutable &str reference.

Source

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.

Source

pub fn len(&self) -> usize

Returns the number of characters used in the string.

Source

pub fn is_empty(&self) -> bool

Returns true if the string has a length of 0

Source

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.

Source

pub fn chars<'a>(&'a self) -> Chars<'a>

Get an immutable iterator to the internal character array.

Source

pub fn chars_mut<'a>(&'a mut self) -> CharsMut<'a>

Get a mutable iterator to the internal character array.

Source

pub fn lines(&self) -> Lines<'_>

Get an iterator over the lines of the internal character array.

Source

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).

Trait Implementations§

Source§

impl AsMut<[AsciiChar]> for PascalStr

Source§

fn as_mut(&mut self) -> &mut [AsciiChar]

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl AsMut<AsciiStr> for PascalStr

Source§

fn as_mut(&mut self) -> &mut AsciiStr

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl AsRef<[AsciiChar]> for PascalStr

Source§

fn as_ref(&self) -> &[AsciiChar]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<[u8]> for PascalStr

Source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<AsciiStr> for PascalStr

Source§

fn as_ref(&self) -> &AsciiStr

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<PascalStr> for PascalStr

Source§

fn as_ref(&self) -> &Self

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<PascalStr> for PascalString

Source§

fn as_ref(&self) -> &PascalStr

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<str> for PascalStr

Source§

fn as_ref(&self) -> &str

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsciiExt for PascalStr

Source§

type Owned = PascalString

👎Deprecated since 1.26.0: use inherent methods instead
Container type for copied ASCII characters.
Source§

fn is_ascii(&self) -> bool

👎Deprecated since 1.26.0: use inherent methods instead
Checks if the value is within the ASCII range. Read more
Source§

fn to_ascii_uppercase(&self) -> Self::Owned

👎Deprecated since 1.26.0: use inherent methods instead
Makes a copy of the value in its ASCII upper case equivalent. Read more
Source§

fn to_ascii_lowercase(&self) -> Self::Owned

👎Deprecated since 1.26.0: use inherent methods instead
Makes a copy of the value in its ASCII lower case equivalent. Read more
Source§

fn eq_ignore_ascii_case(&self, other: &Self) -> bool

👎Deprecated since 1.26.0: use inherent methods instead
Checks that two values are an ASCII case-insensitive match. Read more
Source§

fn make_ascii_uppercase(&mut self)

👎Deprecated since 1.26.0: use inherent methods instead
Converts this type to its ASCII upper case equivalent in-place. Read more
Source§

fn make_ascii_lowercase(&mut self)

👎Deprecated since 1.26.0: use inherent methods instead
Converts this type to its ASCII lower case equivalent in-place. Read more
Source§

impl Borrow<PascalStr> for PascalString

Source§

fn borrow(&self) -> &PascalStr

Immutably borrows from an owned value. Read more
Source§

impl BorrowMut<PascalStr> for PascalString

Source§

fn borrow_mut(&mut self) -> &mut PascalStr

Mutably borrows from an owned value. Read more
Source§

impl Debug for PascalStr

Source§

fn fmt(&self, fmtr: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for PascalStr

Source§

fn fmt(&self, fmtr: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Hash for PascalStr

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
Source§

impl Index<Range<i32>> for PascalStr

Source§

type Output = [AsciiChar]

The returned type after indexing.
Source§

fn index(&self, range: Range<i32>) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl Index<Range<u8>> for PascalStr

Source§

type Output = [AsciiChar]

The returned type after indexing.
Source§

fn index(&self, range: Range<u8>) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl Index<Range<usize>> for PascalStr

Source§

type Output = [AsciiChar]

The returned type after indexing.
Source§

fn index(&self, range: Range<usize>) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl Index<RangeFrom<i32>> for PascalStr

Source§

type Output = [AsciiChar]

The returned type after indexing.
Source§

fn index(&self, range: RangeFrom<i32>) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl Index<RangeFrom<u8>> for PascalStr

Source§

type Output = [AsciiChar]

The returned type after indexing.
Source§

fn index(&self, range: RangeFrom<u8>) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl Index<RangeFrom<usize>> for PascalStr

Source§

type Output = [AsciiChar]

The returned type after indexing.
Source§

fn index(&self, range: RangeFrom<usize>) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl Index<RangeFull> for PascalStr

Source§

type Output = [AsciiChar]

The returned type after indexing.
Source§

fn index(&self, _: RangeFull) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl Index<RangeTo<i32>> for PascalStr

Source§

type Output = [AsciiChar]

The returned type after indexing.
Source§

fn index(&self, range: RangeTo<i32>) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl Index<RangeTo<u8>> for PascalStr

Source§

type Output = [AsciiChar]

The returned type after indexing.
Source§

fn index(&self, range: RangeTo<u8>) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl Index<RangeTo<usize>> for PascalStr

Source§

type Output = [AsciiChar]

The returned type after indexing.
Source§

fn index(&self, range: RangeTo<usize>) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl Index<i32> for PascalStr

Source§

type Output = AsciiChar

The returned type after indexing.
Source§

fn index(&self, index: i32) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl Index<u8> for PascalStr

Source§

type Output = AsciiChar

The returned type after indexing.
Source§

fn index(&self, index: u8) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl Index<usize> for PascalStr

Source§

type Output = AsciiChar

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl IndexMut<Range<i32>> for PascalStr

Source§

fn index_mut(&mut self, range: Range<i32>) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl IndexMut<Range<u8>> for PascalStr

Source§

fn index_mut(&mut self, range: Range<u8>) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl IndexMut<Range<usize>> for PascalStr

Source§

fn index_mut(&mut self, range: Range<usize>) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl IndexMut<RangeFrom<i32>> for PascalStr

Source§

fn index_mut(&mut self, range: RangeFrom<i32>) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl IndexMut<RangeFrom<u8>> for PascalStr

Source§

fn index_mut(&mut self, range: RangeFrom<u8>) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl IndexMut<RangeFrom<usize>> for PascalStr

Source§

fn index_mut(&mut self, range: RangeFrom<usize>) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl IndexMut<RangeFull> for PascalStr

Source§

fn index_mut(&mut self, _: RangeFull) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl IndexMut<RangeTo<i32>> for PascalStr

Source§

fn index_mut(&mut self, range: RangeTo<i32>) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl IndexMut<RangeTo<u8>> for PascalStr

Source§

fn index_mut(&mut self, range: RangeTo<u8>) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl IndexMut<RangeTo<usize>> for PascalStr

Source§

fn index_mut(&mut self, range: RangeTo<usize>) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl IndexMut<i32> for PascalStr

Source§

fn index_mut(&mut self, index: i32) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl IndexMut<u8> for PascalStr

Source§

fn index_mut(&mut self, index: u8) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl IndexMut<usize> for PascalStr

Source§

fn index_mut(&mut self, index: usize) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<'a> IntoIterator for &'a PascalStr

Source§

type Item = &'a AsciiChar

The type of the elements being iterated over.
Source§

type IntoIter = Chars<'a>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'a> IntoIterator for &'a mut PascalStr

Source§

type Item = &'a mut AsciiChar

The type of the elements being iterated over.
Source§

type IntoIter = CharsMut<'a>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl Ord for PascalStr

Source§

fn cmp(&self, other: &PascalStr) -> Ordering

This method returns an Ordering between self and other. Read more
Source§

impl<S: AsRef<PascalStr> + ?Sized> PartialEq<S> for PascalStr

Source§

fn eq(&self, other: &S) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<S: AsRef<PascalStr> + ?Sized> PartialOrd<S> for PascalStr

Source§

fn partial_cmp(&self, other: &S) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl ToOwned for PascalStr

Source§

type Owned = PascalString

The resulting type after obtaining ownership.
Source§

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)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl Eq for PascalStr

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more