text_lines

Crates.iotext_lines
lib.rstext_lines
version0.6.0
sourcesrc
created_at2021-08-13 16:17:11.974627
updated_at2022-07-11 21:51:07.606298
descriptionInformation about lines of text in a string.
homepage
repository
max_upload_size
id435750
size25,502
David Sherret (dsherret)

documentation

README

text_lines

Information about lines of text in a string.

use text_lines::TextLines;

let text = "Line 1\n\tLine 2";
let info = TextLines::new(&text); // defaults to an indent width of 4

let line_index = info.line_index(9); // 1
let line_and_column = info.line_and_column_index(9); // 1, 2
let byte_index = info.byte_index(&line_and_column); // 9
let line_and_column_display = info.line_and_column_display(9); // 2, 6

let info = TextLines::with_indent_width(&text, 2);
let line_and_column_display = info.line_and_column_display(9); // 2, 4
Commit count: 0

cargo fmt