From 39b31c18e9ff16c12cbb723a9d897ca34d9aef6d Mon Sep 17 00:00:00 2001 From: pommicket Date: Sun, 7 Sep 2025 22:55:53 -0400 Subject: Fix issue with whitespace trimming --- examples/conf.pom | 2 +- src/lib.rs | 24 ++++++++++-------------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/examples/conf.pom b/examples/conf.pom index 5fe5fbb..90483f6 100644 --- a/examples/conf.pom +++ b/examples/conf.pom @@ -1 +1 @@ -fav-colour = green +fav-colour = `green` diff --git a/src/lib.rs b/src/lib.rs index 55a407c..16329bd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -115,28 +115,25 @@ impl fmt::Display for Error { match self { Self::IO(message, io_err) => write!(f, "{message}: {io_err}"), Self::IllegalCharacter(location, c) => { - write!(f, "{location}: illegal character {}", c.escape_debug()) + write!(f, "{location}: illegal character {c:?}") } Self::InvalidUtf8(location) => write!(f, "{location}: invalid UTF-8"), Self::BadInt(location, value) => { - write!(f, "{location}: invalid integer: {}", value.escape_debug()) + write!(f, "{location}: invalid integer: {value:?}") + } + Self::BadUInt(location, value) => { + write!(f, "{location}: invalid (unsigned) integer: {value:?}",) } - Self::BadUInt(location, value) => write!( - f, - "{location}: invalid (unsigned) integer: {}", - value.escape_debug() - ), Self::BadFloat(location, value) => { - write!(f, "{location}: invalid number: {}", value.escape_debug()) + write!(f, "{location}: invalid number: {value:?}") } Self::BadBool(location, value) => write!( f, - "{location}: value {} should be off/false/no or on/true/yes", - value.escape_debug() + "{location}: value {value:?} should be off/false/no or on/true/yes", ), Self::UnmatchedLeftBrace(location) => write!(f, "{location}: [ has no matching ]"), Self::InvalidKey(location, key) => { - write!(f, "{location}: invalid key {}", key.escape_debug()) + write!(f, "{location}: invalid key {key:?}") } Self::InvalidValue(location) => write!(f, "{location}: value contains null characters"), Self::InvalidLine(location) => write!( @@ -151,8 +148,7 @@ impl fmt::Display for Error { } Self::InvalidEscapeSequence(location, sequence) => write!( f, - "{location}: invalid escape sequence {} (try using \\\\ instead of \\ maybe?)", - sequence.escape_debug() + "{location}: invalid escape sequence {sequence:?} (try using \\\\ instead of \\ maybe?)", ), Self::Multiple(errs) => { let mut first = true; @@ -524,8 +520,8 @@ impl Parser { let (mut relative_key, mut value) = line .split_once('=') .ok_or_else(|| Error::InvalidLine(location.clone()))?; - self.check_valid_key(&location, relative_key); relative_key = relative_key.trim_end_matches(['\t', ' ']); + self.check_valid_key(&location, relative_key); value = value.trim_start_matches(['\t', ' ']); fn insert( -- cgit v1.2.3