1 个稳定版本

1.0.0 2024年7月23日

#7#locations

Download history • Rust 包仓库 158/week @ 2024-07-22 • Rust 包仓库 10/week @ 2024-07-29 • Rust 包仓库 24/week @ 2024-08-12 • Rust 包仓库

192 每月下载量
6 个crate中使用 (2 个直接使用)

Apache-2.0

15KB
298

源文本

一个用于存储从 std::string::String 中获取的行偏移和列的库。它在第一次调用任何检索方法时只处理行一次。

示例

以下是一个基本示例

// offset 5 = "bar"
let text = SourceText::new("foo\r\nbar\r\nqux".into());
assert_eq!(0, text.get_column(5));
assert_eq!(2, text.get_line_number(5));
assert_eq!(5, text.get_line_offset(2).unwrap());
assert_eq!(5, text.get_line_offset_from_offset(7));

无运行时依赖