Implementation of std::scanner::Error for ScanError

This commit is contained in:
m-r-r 2015-06-18 23:49:28 +02:00
parent 3c9da807e5
commit 34f81af101

View file

@ -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,