pub struct AsciiTable { /* private fields */ }Expand description
Represents a table of ASCII characters.
The table is implemented as a HashMap
of Byte values to AsciiChar
It maps the valid ASCII Byte values to their
corresponding AsciiChar values.
§Examples
use brainfoamkit_lib::{
AsciiTable,
Byte,
};
let ascii_table = AsciiTable::new();
assert_eq!(
ascii_table.get(Byte::from(0)).unwrap().character_code(),
"CNUL"
);
assert_eq!(
ascii_table.get(Byte::from(1)).unwrap().character_code(),
"CSOH"
);
assert_eq!(
ascii_table.get(Byte::from(2)).unwrap().character_code(),
"CSTX"
);§References
Implementations§
Source§impl AsciiTable
impl AsciiTable
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new AsciiTable instance.
This will create a new AsciiTable instance
with all the valid ASCII characters pre-populated.
§Examples
use brainfoamkit_lib::{
AsciiTable,
Byte,
};
let ascii_table = AsciiTable::new();
assert_eq!(
ascii_table.get(Byte::from(0)).unwrap().character_code(),
"CNUL"
);§References
Sourcepub fn get(&self, byte: Byte) -> Option<&AsciiChar>
pub fn get(&self, byte: Byte) -> Option<&AsciiChar>
Get an ASCII character from the table by its byte value.
§Arguments
byte- TheBytevalue of the ASCII character to get.
§Returns
Some(&AsciiChar)- TheAsciiCharvalue corresponding to the given Byte value.None- If the givenBytevalue does not correspond to an ASCII character.
§Examples
use brainfoamkit_lib::{
AsciiTable,
Byte,
};
let ascii_table = AsciiTable::new();
assert_eq!(
ascii_table.get(Byte::from(0)).unwrap().character_code(),
"CNUL"
);
assert_eq!(
ascii_table.get(Byte::from(1)).unwrap().character_code(),
"CSOH"
);
assert_eq!(
ascii_table.get(Byte::from(2)).unwrap().character_code(),
"CSTX"
);Trait Implementations§
Auto Trait Implementations§
impl Freeze for AsciiTable
impl RefUnwindSafe for AsciiTable
impl Send for AsciiTable
impl Sync for AsciiTable
impl Unpin for AsciiTable
impl UnwindSafe for AsciiTable
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