pub enum Token {
Num(f64),
Int(i64),
Str(String),
Iden(String),
Char(char),
Error(ScanError),
End,
}
Expand description
Represents a token returned by Scanner::get
Variants§
Num(f64)
a floating-point number, stored as double-precision float
Int(i64)
an integer, stored as eight-byte unsigned
Str(String)
a quoted string
Iden(String)
an identifier \a+[\a\d_]*
Char(char)
a character (anything not recognized as any of the above
Error(ScanError)
represents an error
End
end of stream
Implementations§
Source§impl Token
impl Token
Sourcepub fn to_float_result(self) -> Result<f64, ScanError>
pub fn to_float_result(self) -> Result<f64, ScanError>
extract the float, or complain
Sourcepub fn is_integer(&self) -> bool
pub fn is_integer(&self) -> bool
is this token an integer?
Sourcepub fn to_integer(self) -> Option<i64>
pub fn to_integer(self) -> Option<i64>
extract the integer
Sourcepub fn to_integer_result(self) -> Result<i64, ScanError>
pub fn to_integer_result(self) -> Result<i64, ScanError>
extract the integer, or complain
Sourcepub fn to_int_result<I: Int>(self) -> Result<I::Type, ScanError>
pub fn to_int_result<I: Int>(self) -> Result<I::Type, ScanError>
extract the integer as a particular subtype
Sourcepub fn to_number_result(self) -> Result<f64, ScanError>
pub fn to_number_result(self) -> Result<f64, ScanError>
extract the number, not caring about float or integer, or complain
Sourcepub fn to_string_result(self) -> Result<String, ScanError>
pub fn to_string_result(self) -> Result<String, ScanError>
extract the string, or complain
Sourcepub fn to_iden_result(self) -> Result<String, ScanError>
pub fn to_iden_result(self) -> Result<String, ScanError>
extract the identifier, or complain
Sourcepub fn to_char_result(self) -> Result<char, ScanError>
pub fn to_char_result(self) -> Result<char, ScanError>
extract the character, or complain
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Token
impl RefUnwindSafe for Token
impl Send for Token
impl Sync for Token
impl Unpin for Token
impl UnwindSafe for Token
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