Struct brainfoamkit_lib::AsciiTable
source · 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
- TheByte
value of the ASCII character to get.
§Returns
Some(&AsciiChar)
- TheAsciiChar
value corresponding to the given Byte value.None
- If the givenByte
value 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