Expand description
§use-line
Composable line-level text primitives for RustUse.
use-line provides small helpers for line counting, indentation, dedentation, and line-ending
normalization. It stays explicit about logical lines and keeps the behavior predictable across
LF, CRLF, and CR inputs.
§Included primitives
line_countnon_empty_line_counttrim_linesnormalize_line_endingsindent_linesdedent_lineslines_with_numbers
§Example
use use_line::{dedent_lines, line_count, lines_with_numbers, LineEnding};
assert_eq!(line_count("alpha\nbeta\n"), 2);
assert_eq!(dedent_lines(" alpha\n beta"), "alpha\n beta");
assert_eq!(lines_with_numbers("alpha")[0].number.get(), 1);
assert_eq!(LineEnding::Crlf.as_str(), "\r\n");Structs§
- Line
- A numbered logical line.
- Line
Number - A 1-based line number.
- Line
Stats - Aggregate line counts derived from text.
Enums§
- Line
Ending - Supported line-ending shapes.
Functions§
- dedent_
lines - Removes the common indentation shared by non-empty lines.
- indent_
lines - Prefixes each logical line with the provided indent string.
- line_
count - Counts logical lines, ignoring a trailing empty line created only by a final line ending.
- lines_
with_ numbers - Returns numbered logical lines.
- non_
empty_ line_ count - Counts logical lines whose trimmed content is not empty.
- normalize_
line_ endings - Normalizes line endings to the requested target.
- trim_
lines - Trims each logical line independently and preserves the input line-ending style when possible.