trim-newlines
Trim newlines from the start and/or end of a string.
Removes leading and trailing newline characters — \r and \n only, not other
whitespace. A faithful Rust port of the widely-used
trim-newlines npm package.
- Zero dependencies,
#![no_std] - Returns a borrowed
&strslice (no allocation) - Differential-tested against the reference
trim-newlinesimplementation
Install
[]
= "0.1"
Usage
use ;
assert_eq!;
assert_eq!;
assert_eq!;
// Only newlines are trimmed — spaces and tabs are preserved:
assert_eq!;
Contributors ✨
This project follows the all-contributors specification. Contributions of any kind are welcome — code, docs, bug reports, ideas, reviews! See the emoji key for how each contribution is recognized, and open a PR or issue to get involved.
Thanks goes to these wonderful people:
License
Licensed under either of MIT or Apache-2.0 at your option.