[−][src]Function ascii::caret_decode
pub fn caret_decode<C: Copy + Into<u8>>(c: C) -> Option<AsciiChar>
Returns the control code represented by a caret notation
letter, or None
if the letter is not used in caret notation.
This function is the inverse of caret_encode()
.
Examples
Basic usage:
assert_eq!(caret_decode(b'?'), Some(AsciiChar::DEL)); assert_eq!(caret_decode(AsciiChar::D), Some(AsciiChar::EOT)); assert_eq!(caret_decode(b'\0'), None);
Symmetry:
assert_eq!(caret_encode(AsciiChar::US).and_then(caret_decode), Some(AsciiChar::US)); assert_eq!(caret_decode(b'@').and_then(caret_encode), Some(AsciiChar::At));