pub struct AsciiSet { /* private fields */ }
Expand description
A set of ASCII characters.
§Examples
let set1 = AsciiSet::new((1 << b'A') | (1 << b'B') | (1 << b'C'));
assert_eq!(set1.len(), 3);
assert_eq!(set1.to_string(), "'A', 'B', 'C'");
assert_eq!(format!("{set1:?}"), "{'A', 'B', 'C'}");
let mut array = [false; 128];
array[b'A' as usize] = true;
array[b'B' as usize] = true;
array[b'C' as usize] = true;
assert_eq!(AsciiSet::from(array), set1);
assert_eq!(AsciiSet::from(|b| (b'A'..=b'C').contains(&b)), set1);
Implementations§
Trait Implementations§
Source§impl Display for AsciiSet
Format the set for display, combining digit and letter ranges.
impl Display for AsciiSet
Format the set for display, combining digit and letter ranges.
§Examples
assert_eq!(
AsciiSet::from(|b: u8| b.is_ascii_lowercase()).to_string(),
"'a'-'z'"
);
assert_eq!(
AsciiSet::from(|b: u8| b.is_ascii_alphabetic()).to_string(),
"'A'-'Z', 'a'-'z'"
);
assert_eq!(
AsciiSet::from(|b: u8| matches!(b, b'.' | b'#' | b'0'..=b'9')).to_string(),
"'#', '.', '0'-'9'"
);
assert_eq!(
AsciiSet::from(|b: u8| b.is_ascii_graphic()).to_string(),
concat!(
"'!', '\"', '#', '$', '%', '&', '\\'', '(', ')', '*', '+', ',', '-', '.', '/', ",
"'0'-'9', ':', ';', '<', '=', '>', '?', '@', 'A'-'Z', '[', '\\\\', ']', '^', '_', ",
"'`', 'a'-'z', '{', '|', '}', '~'"
)
);
impl Copy for AsciiSet
impl Eq for AsciiSet
impl StructuralPartialEq for AsciiSet
Auto Trait Implementations§
impl Freeze for AsciiSet
impl RefUnwindSafe for AsciiSet
impl Send for AsciiSet
impl Sync for AsciiSet
impl Unpin for AsciiSet
impl UnwindSafe for AsciiSet
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more