Implementation of std::scanner::Error for ScanError
This commit is contained in:
parent
ce7af9dc6e
commit
a52b22a165
1 changed files with 18 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
|||
use std::collections::VecDeque;
|
||||
use std::char;
|
||||
use std::{char, fmt};
|
||||
use std::error::Error;
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Debug, Eq)]
|
||||
pub enum TEncoding {
|
||||
|
@ -49,6 +50,22 @@ impl ScanError {
|
|||
}
|
||||
}
|
||||
|
||||
impl Error for ScanError {
|
||||
fn description(&self) -> &str {
|
||||
self.info.as_ref()
|
||||
}
|
||||
|
||||
fn cause(&self) -> Option<&Error> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for ScanError {
|
||||
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||
self.info.fmt(formatter)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Debug, Eq)]
|
||||
pub enum TokenType {
|
||||
NoToken,
|
||||
|
|
Loading…
Reference in a new issue