Skip to content

Commit

Permalink
new: remove trailing whitespace in message and string values
Browse files Browse the repository at this point in the history
  • Loading branch information
pamburus committed Mar 20, 2024
1 parent a4ef28b commit fe5a72c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ categories = ["command-line-utilities"]
description = "Utility for viewing json-formatted log files."
keywords = ["cli", "human", "log"]
name = "hl"
version = "0.27.0-beta.3.3"
version = "0.27.0-beta.3.4"
edition = "2021"
build = "build.rs"

Expand Down
4 changes: 4 additions & 0 deletions src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ impl<'a> RawValue<'a> {

#[inline]
pub fn format_as_str(&self, buf: &mut Vec<u8>) {
let begin = buf.len();
match self {
Self::Json(value) => {
let mut reader = StrRead::new(&value.get()[1..]);
Expand All @@ -139,6 +140,9 @@ impl<'a> RawValue<'a> {
.unwrap();
}
}
if let Some(end) = buf[begin..].iter().rposition(|&b| !b.is_ascii_whitespace()) {
buf.truncate(begin + end + 1);
}
}

#[inline]
Expand Down

0 comments on commit fe5a72c

Please sign in to comment.