Skip to content

Commit 52fdc72

Browse files
authored
Merge pull request #94 from zimbatm/chore-fixes
Chore fixes
2 parents e948564 + 1afeef8 commit 52fdc72

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

flake.nix

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@
4848
./Cargo.toml
4949
./Cargo.lock
5050
./src
51+
./spec.clear.md
52+
./spec.processed.md
53+
./samples
5154
];
5255
};
5356

src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ pub mod cli;
22
pub mod executor;
33
mod nom_ext;
44
pub mod parser;
5-
#[cfg(test)]
6-
mod tests;
75

86
use std::io::Write;
97

src/main.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ use std::{
44
};
55

66
use anyhow::Context;
7+
8+
/// Trims trailing ASCII whitespace from a byte slice.
9+
/// Stable alternative to the unstable `trim_ascii_end()` method.
10+
fn trim_ascii_end(bytes: &[u8]) -> &[u8] {
11+
let mut end = bytes.len();
12+
while end > 0 && bytes[end - 1].is_ascii_whitespace() {
13+
end -= 1;
14+
}
15+
&bytes[..end]
16+
}
717
use clap::Parser;
818
use mdsh::{
919
cli::{FileArg, Opt, Parent},
@@ -71,7 +81,7 @@ fn process_file(
7181
}
7282
let file_unmodified_check = !frozen || input_content.as_bytes() == buffer;
7383

74-
std::fs::write(outf, buffer.trim_ascii_end())
84+
std::fs::write(outf, trim_ascii_end(&buffer))
7585
.with_context(|| format!("failed to write file {outf:?}"))?;
7686

7787
file_unmodified_check

0 commit comments

Comments
 (0)