summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2025-09-07 22:55:53 -0400
committerpommicket <pommicket@gmail.com>2025-09-07 22:55:53 -0400
commit39b31c18e9ff16c12cbb723a9d897ca34d9aef6d (patch)
tree7b56e45573cc2a1b8c282579dd5b549fb866e906 /src
parent8d5b16efda7c21fabd3cec655d143ed3e78ea5e6 (diff)
Fix issue with whitespace trimming
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs24
1 files changed, 10 insertions, 14 deletions
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(