Merge pull request #124 from vemoo/impl-display

implement fmt::Display instead of ToString
This commit is contained in:
Nikhil Benesch 2019-07-01 16:24:53 -04:00 committed by GitHub
commit ed76cd68f8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 605 additions and 550 deletions

View file

@ -19,6 +19,7 @@ use super::dialect::keywords;
use super::dialect::Dialect;
use super::tokenizer::*;
use std::error::Error;
use std::fmt;
#[derive(Debug, Clone, PartialEq)]
pub enum ParserError {
@ -52,8 +53,8 @@ impl From<TokenizerError> for ParserError {
}
}
impl std::fmt::Display for ParserError {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
impl fmt::Display for ParserError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(
f,
"sql parser error: {}",
@ -728,7 +729,7 @@ impl Parser {
parser_err!(format!(
"Expected {}, found: {}",
expected,
found.map_or("EOF".to_string(), |t| t.to_string())
found.map_or_else(|| "EOF".to_string(), |t| format!("{}", t))
))
}