Merge pull request #1 from m-r-r/error-types
Implementation of std::scanner::Error for ScanError
This commit is contained in:
commit
de1d4a4bda
1 changed files with 18 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
use std::char;
|
use std::{char, fmt};
|
||||||
|
use std::error::Error;
|
||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq, Debug, Eq)]
|
#[derive(Clone, Copy, PartialEq, Debug, Eq)]
|
||||||
pub enum TEncoding {
|
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)]
|
#[derive(Clone, PartialEq, Debug, Eq)]
|
||||||
pub enum TokenType {
|
pub enum TokenType {
|
||||||
NoToken,
|
NoToken,
|
||||||
|
|
Loading…
Reference in a new issue