diff options
| author | Laurențiu Nicola <lnicola@dend.ro> | 2024-01-08 11:29:25 +0200 |
|---|---|---|
| committer | Laurențiu Nicola <lnicola@dend.ro> | 2024-01-08 11:29:25 +0200 |
| commit | fd63ff0f25ec9077fb013c7457072c546d11a31f (patch) | |
| tree | dcf19b38c4cd4e71a0aacbc5b7d2f9f5a988d6a9 /src/tools/rust-analyzer/lib | |
| parent | 0ee9cfd54db7b5f4be35f026588904500c866196 (diff) | |
| parent | af40101841c45aa75b56f4e9ca745369da8fb4ba (diff) | |
Merge commit 'af40101841c45aa75b56f4e9ca745369da8fb4ba' into sync-from-ra
Diffstat (limited to 'src/tools/rust-analyzer/lib')
| -rw-r--r-- | src/tools/rust-analyzer/lib/line-index/README.md | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/tools/rust-analyzer/lib/line-index/README.md b/src/tools/rust-analyzer/lib/line-index/README.md new file mode 100644 index 00000000000..93ac03696a0 --- /dev/null +++ b/src/tools/rust-analyzer/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. |
