diff options
| author | bors <bors@rust-lang.org> | 2024-01-07 14:41:45 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-01-07 14:41:45 +0000 |
| commit | af40101841c45aa75b56f4e9ca745369da8fb4ba (patch) | |
| tree | 44df12c994e72e35b24cd243157fae5ce93f14a7 | |
| parent | 6ce3f44597a1fb78a6ec67d087c2f725c006515c (diff) | |
| parent | 0f69276e60cd9636e6ad2c76dcc9f68619cc6851 (diff) | |
| download | rust-af40101841c45aa75b56f4e9ca745369da8fb4ba.tar.gz rust-af40101841c45aa75b56f4e9ca745369da8fb4ba.zip | |
Auto merge of #16302 - homersimpsons:patch-1, r=lnicola
line-index: Create README.md Fixes #16180
| -rw-r--r-- | lib/line-index/README.md | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/line-index/README.md b/lib/line-index/README.md new file mode 100644 index 00000000000..93ac03696a0 --- /dev/null +++ b/lib/line-index/README.md @@ -0,0 +1,30 @@ +# line-index + +This crate is developed as part of `rust-analyzer`. + +line-index is a library to convert between text offsets and corresponding line/column coordinates. + +## Installation + +To add this crate to a project simply run `cargo add line-index`. + +## Usage + +The main structure is `LineIndex`. + +It is constructed with an UTF-8 string, but also supports UTF-16 and UTF-32 offsets. + +### Example + +```rust +use line_index::LineIndex; + +let line_index = LineIndex::new("This is a\nmulti-line\ntext."); +line_index.line_col(3.into()); // LineCol { line: 0, col: 3 } +line_index.line_col(13.into()); // LineCol { line: 1, col: 3 } +line_index.offset(LineCol { line: 2, col: 3 }); // Some (24) +``` + +## SemVer + +This crate uses [semver](https://semver.org/) versioning. |
