trim-newlines 0.1.0

Trim newlines (\r and \n) from the start and/or end of a string. A faithful port of the trim-newlines npm package. Zero deps, no_std.
Documentation
# trim-newlines

[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors-)

[![crates.io](https://img.shields.io/crates/v/trim-newlines.svg)](https://crates.io/crates/trim-newlines)
[![docs.rs](https://docs.rs/trim-newlines/badge.svg)](https://docs.rs/trim-newlines)
[![CI](https://github.com/trananhtung/trim-newlines/actions/workflows/ci.yml/badge.svg)](https://github.com/trananhtung/trim-newlines/actions/workflows/ci.yml)
[![license](https://img.shields.io/crates/l/trim-newlines.svg)](#license)

**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`](https://www.npmjs.com/package/trim-newlines) npm package.

- **Zero dependencies**, **`#![no_std]`**
- Returns a borrowed `&str` slice (no allocation)
- Differential-tested against the reference `trim-newlines` implementation

## Install

```toml
[dependencies]
trim-newlines = "0.1"
```

## Usage

```rust
use trim_newlines::{trim_newlines, trim_newlines_start, trim_newlines_end};

assert_eq!(trim_newlines("\n\nfoo\n\n"), "foo");
assert_eq!(trim_newlines_start("\r\nbar\r\n"), "bar\r\n");
assert_eq!(trim_newlines_end("\r\nbar\r\n"), "\r\nbar");

// Only newlines are trimmed — spaces and tabs are preserved:
assert_eq!(trim_newlines("  spaced  "), "  spaced  ");
```

## Contributors ✨

This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind are welcome — code, docs, bug reports, ideas, reviews! See the [emoji key](https://allcontributors.org/docs/en/emoji-key) for how each contribution is recognized, and open a PR or issue to get involved.

Thanks goes to these wonderful people:

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<table>
  <tbody>
    <tr>
      <td align="center" valign="top" width="14.28%"><a href="https://github.com/trananhtung"><img src="https://avatars.githubusercontent.com/u/30992229?v=4?s=100" width="100px;" alt="Tung Tran"/><br /><sub><b>Tung Tran</b></sub></a><br /><a href="https://github.com/trananhtung/./commits?author=trananhtung" title="Code">💻</a> <a href="#maintenance-trananhtung" title="Maintenance">🚧</a></td>
    </tr>
  </tbody>
</table>

<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->

<!-- ALL-CONTRIBUTORS-LIST:END -->

## License

Licensed under either of [MIT](LICENSE-MIT) or [Apache-2.0](LICENSE-APACHE) at your option.