normalized_line_endings/lib.rs
1//! # Iterator over characters with normalized line endings
2//!
3//! The **Normalized line endings** crate provides an iterator over characters
4//! with normalized line endings, meaning all valid line endings in the input
5//! are converted to a single newline character `\n` (U+000A), like this:
6//!
7//! - `\n` → `\n`
8//! - `\r` → `\n`
9//! - `\r\n` → `\n`
10//!
11//! The normalized iterator can be created using standalone function [normalized()]
12//! or by calling the method [Normalized::normalized] on any iterator over characters.
13//!
14//! # Examples
15//!
16//! ## Using standalone function [normalized()]
17//!
18//! ```
19//! use normalized_line_endings::normalized;
20//!
21//! let input = "This is a string \n with \r some \n\r\n random newlines\r\r\n\n";
22//! assert_eq!(
23//! "This is a string \n with \n some \n\n random newlines\n\n\n",
24//! normalized(input.chars()).collect::<String>()
25//! );
26//! ```
27//!
28//! ## Using [Normalized] trait extension
29//!
30//! ```
31//! use normalized_line_endings::Normalized;
32//!
33//! let input = "This is a string \n with \r some \n\r\n random newlines\r\r\n\n";
34//! assert_eq!(
35//! "This is a string \n with \n some \n\n random newlines\n\n\n",
36//! input.chars().normalized().collect::<String>()
37//! );
38//! ```
39
40#![no_std]
41#![deny(missing_docs)]
42#![deny(rustdoc::broken_intra_doc_links)]
43#![deny(rustdoc::missing_crate_level_docs)]
44
45mod annotated;
46mod common;
47mod line_ending;
48mod normalized;
49
50pub use annotated::{annotated, Annotated, AnnotatedChar};
51pub use common::{CR, LF};
52pub use line_ending::LineEnding;
53pub use normalized::{normalized, Normalized};