pub struct fstr<const N: usize> { /* private fields */ }
Expand description
main type: string of size up to const N:
Implementations
sourceimpl<const N: usize> fstr<N>
impl<const N: usize> fstr<N>
sourcepub fn make(s: &str) -> fstr<N>
pub fn make(s: &str) -> fstr<N>
creates a new fstr
sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
length of the string in bytes, which will be up to the maximum size N. This is a constant-time operation. Note that this value is consistent with str::len
sourcepub fn to_str(&self) -> &str
pub fn to_str(&self) -> &str
converts fstr to &str using std::str::from_utf8
sourcepub fn as_str(&self) -> &str
pub fn as_str(&self) -> &str
alias for fstr::to_str
sourcepub fn set(&mut self, i: usize, c: char) -> bool
pub fn set(&mut self, i: usize, c: char) -> bool
changes a character at character position i to c. This function requires that c is in the same character class (ascii or unicode) as the char being replaced. It never shuffles the bytes underneath. The function returns true if the change was successful.
sourcepub fn push<'t>(&mut self, s: &'t str) -> &'t str
pub fn push<'t>(&mut self, s: &'t str) -> &'t str
adds chars to end of current string up to maximum size N of fstr
sourcepub fn charlen(&self) -> usize
pub fn charlen(&self) -> usize
returns the number of characters in the string regardless of character class
sourcepub fn nth_ascii(&self, n: usize) -> char
pub fn nth_ascii(&self, n: usize) -> char
returns the nth byte of the string as a char. This function should only be called on ascii strings. It is designed to be quicker than fstr::nth, and does not check array bounds or check n against the length of the string. Nor does it check if the value returned is within the ascii range.
sourceimpl<const M: usize> fstr<M>
impl<const M: usize> fstr<M>
sourcepub fn resize<const N: usize>(&self) -> fstr<N>
pub fn resize<const N: usize>(&self) -> fstr<N>
converts an fstr<M> to an fstr<N>. If the length of the string being converted is greater than N, the extra characters will be ignored. This operation produces a copy (non-destructive). Example:
let s1:fstr<8> = fstr::from("abcdefg");
let s2:fstr<16> = s1.resize();
sourceimpl<const N: usize> fstr<N>
impl<const N: usize> fstr<N>
sourcepub fn char_indices(&self) -> CharIndices<'_>
pub fn char_indices(&self) -> CharIndices<'_>
mimics same function on str
Trait Implementations
sourceimpl<IndexType, const N: usize> Index<IndexType> for fstr<N> where
IndexType: SliceIndex<[u8]>,
impl<IndexType, const N: usize> Index<IndexType> for fstr<N> where
IndexType: SliceIndex<[u8]>,
Convert fstr to &u8 slice
sourceimpl<const N: usize> Ord for fstr<N>
impl<const N: usize> Ord for fstr<N>
sourceimpl<const N: usize> PartialOrd<fstr<N>> for fstr<N>
impl<const N: usize> PartialOrd<fstr<N>> for fstr<N>
sourcefn partial_cmp(&self, other: &Self) -> Option<Ordering>
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl<const N: usize> Copy for fstr<N>
impl<const N: usize> Eq for fstr<N>
impl<const N: usize> StructuralEq for fstr<N>
impl<const N: usize> StructuralPartialEq for fstr<N>
Auto Trait Implementations
impl<const N: usize> RefUnwindSafe for fstr<N>
impl<const N: usize> Send for fstr<N>
impl<const N: usize> Sync for fstr<N>
impl<const N: usize> Unpin for fstr<N>
impl<const N: usize> UnwindSafe for fstr<N>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more