about summary refs log tree commit diff
path: root/src/tools/rust-analyzer/lib
diff options
context:
space:
mode:
authorLaurențiu Nicola <lnicola@dend.ro>2024-01-08 11:29:25 +0200
committerLaurențiu Nicola <lnicola@dend.ro>2024-01-08 11:29:25 +0200
commitfd63ff0f25ec9077fb013c7457072c546d11a31f (patch)
treedcf19b38c4cd4e71a0aacbc5b7d2f9f5a988d6a9 /src/tools/rust-analyzer/lib
parent0ee9cfd54db7b5f4be35f026588904500c866196 (diff)
parentaf40101841c45aa75b56f4e9ca745369da8fb4ba (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.md30
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.