pub struct CharList { /* private fields */ }Expand description
Implementations
sourceimpl CharList
impl CharList
sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the length of self.
This length is in bytes, not chars or graphemes. In other words,
it might not be what a human considers the length of the string.
Examples
Basic usage:
let foo = CharList::from("foo");
assert!(foo.len() == 3);
let fancy_foo = CharList::from("ƒoo"); // fancy f!
assert!(fancy_foo.len() == 4);
assert!(fancy_foo.chars().count() == 3);pub fn is_empty(&self) -> bool
pub fn chars(&self) -> Chars<'_>
pub fn with_capacity(capacity: usize) -> Self
sourcepub fn car_cdr(&self) -> Option<(char, Self)>
pub fn car_cdr(&self) -> Option<(char, Self)>
Returns a pair containing the first character of self and a
CharList made up of everything after the first character of self.
Returns None if self is empty.
Example
let (g, oats) = CharList::from("goats").car_cdr().unwrap();
assert!((g, oats) == ('g', CharList::from("oats")));
let empty = CharList::new();
assert!(empty.car_cdr() == None);sourcepub fn as_str(&self) -> &str
pub fn as_str(&self) -> &str
Extracts a string slice which references self’s entire view of the
underlying text.
pub fn from_utf8(vec: Vec<u8>) -> Result<Self, FromUtf8Error>
pub fn from_utf8_lossy(bytes: &[u8]) -> Self
sourcepub unsafe fn from_utf8_unchecked(bytes: &[u8]) -> Self
pub unsafe fn from_utf8_unchecked(bytes: &[u8]) -> Self
Safety
See str::from_utf8_unchecked for
safety requirements.
sourcepub fn without_prefix<'a, P>(&'a self, prefix: P) -> Option<Self>where
P: Pattern<'a>,
pub fn without_prefix<'a, P>(&'a self, prefix: P) -> Option<Self>where
P: Pattern<'a>,
Returns an optional CharList representing self if prefix had been
removed from the front.
let creepy_book = CharList::from("necronomicon");
let informational_book = creepy_book.without_prefix("necro");
assert!(informational_book == Some(CharList::from("nomicon")));Trait Implementations
sourceimpl AddAssign<CharList> for String
impl AddAssign<CharList> for String
sourcefn add_assign(&mut self, rhs: CharList)
fn add_assign(&mut self, rhs: CharList)
Performs the
+= operation. Read moresourceimpl FromIterator<char> for CharList
impl FromIterator<char> for CharList
sourcefn from_iter<I: IntoIterator<Item = char>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = char>>(iter: I) -> Self
Given an iterator over the &str "abc", the CharList "abc"
will be created.
sourceimpl Ord for CharList
impl Ord for CharList
1.21.0 · sourceconst fn max(self, other: Self) -> Selfwhere
Self: Sized,
const fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 · sourceconst fn min(self, other: Self) -> Selfwhere
Self: Sized,
const fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
1.50.0 · sourceconst fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
const fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl<S> PartialOrd<S> for CharListwhere
S: AsRef<str>,
impl<S> PartialOrd<S> for CharListwhere
S: AsRef<str>,
sourcefn partial_cmp(&self, other: &S) -> Option<Ordering>
fn partial_cmp(&self, other: &S) -> Option<Ordering>
1.0.0 · sourceconst fn le(&self, other: &Rhs) -> bool
const 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 moreimpl Eq for CharList
Auto Trait Implementations
impl RefUnwindSafe for CharList
impl !Send for CharList
impl !Sync for CharList
impl Unpin for CharList
impl UnwindSafe for CharList
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
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