pub struct Nag(pub u8);Expand description
A numeric annotation glyph like ?, !! or $42.
Tuple Fields§
§0: u8Implementations§
Source§impl Nag
impl Nag
Sourcepub const BRILLIANT_MOVE: Nag
pub const BRILLIANT_MOVE: Nag
A brilliant move (!!).
Sourcepub const SPECULATIVE_MOVE: Nag
pub const SPECULATIVE_MOVE: Nag
A speculative move (!?).
Sourcepub const DUBIOUS_MOVE: Nag
pub const DUBIOUS_MOVE: Nag
A dubious move (?!).
Sourcepub fn from_ascii(s: &[u8]) -> Result<Nag, InvalidNag>
pub fn from_ascii(s: &[u8]) -> Result<Nag, InvalidNag>
Tries to parse a NAG from ASCII.
§Examples
use pgn_reader::Nag;
assert_eq!(Nag::from_ascii(b"??"), Ok(Nag(4)));
assert_eq!(Nag::from_ascii(b"$24"), Ok(Nag(24)));§Errors
Returns an InvalidNag error if the input is neither a known glyph
(?!, !, …) nor a valid numeric annotation ($0, …, $255).
Sourcepub fn append_to_string(&self, s: &mut String)
pub fn append_to_string(&self, s: &mut String)
Appends the NAG to a string.
§Examples
use pgn_reader::Nag;
let mut buf = String::new();
Nag(255).append_to_string(&mut buf);
assert_eq!(buf, "$255");Sourcepub fn append_ascii_to(&self, buf: &mut Vec<u8>)
pub fn append_ascii_to(&self, buf: &mut Vec<u8>)
Appends the NAG as ASCII to a byte buffer.
§Examples
use pgn_reader::Nag;
let mut buf = Vec::new();
Nag(255).append_ascii_to(&mut buf);
assert_eq!(buf, b"$255");Trait Implementations§
Source§impl Ord for Nag
impl Ord for Nag
Source§impl PartialOrd for Nag
impl PartialOrd for Nag
impl Copy for Nag
impl Eq for Nag
impl StructuralPartialEq for Nag
Auto Trait Implementations§
impl Freeze for Nag
impl RefUnwindSafe for Nag
impl Send for Nag
impl Sync for Nag
impl Unpin for Nag
impl UnwindSafe for Nag
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