File tree Expand file tree Collapse file tree 3 files changed +14
-3
lines changed
Expand file tree Collapse file tree 3 files changed +14
-3
lines changed Original file line number Diff line number Diff line change 4848 ./Cargo.toml
4949 ./Cargo.lock
5050 ./src
51+ ./spec.clear.md
52+ ./spec.processed.md
53+ ./samples
5154 ] ;
5255 } ;
5356
Original file line number Diff line number Diff line change @@ -2,8 +2,6 @@ pub mod cli;
22pub mod executor;
33mod nom_ext;
44pub mod parser;
5- #[ cfg( test) ]
6- mod tests;
75
86use std:: io:: Write ;
97
Original file line number Diff line number Diff line change @@ -4,6 +4,16 @@ use std::{
44} ;
55
66use 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+ }
717use clap:: Parser ;
818use 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
You can’t perform that action at this time.
0 commit comments