diff options
| author | homersimpsons <guillaume.alabre@gmail.com> | 2024-01-07 14:25:42 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-01-07 14:25:42 +0100 |
| commit | 747fa7dd6ec269ce25a44f67a13450b393a15f9e (patch) | |
| tree | 06c7600c2309a3492c727a84174127fcb6343a8a | |
| parent | 6ce3f44597a1fb78a6ec67d087c2f725c006515c (diff) | |
| download | rust-747fa7dd6ec269ce25a44f67a13450b393a15f9e.tar.gz rust-747fa7dd6ec269ce25a44f67a13450b393a15f9e.zip | |
line-index: Create README.md
| -rw-r--r-- | lib/line-index/README.md | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/line-index/README.md b/lib/line-index/README.md new file mode 100644 index 00000000000..c0d310c857c --- /dev/null +++ b/lib/line-index/README.md @@ -0,0 +1,28 @@ +# line-index + +This crate is developped as part of `rust-analyzer`. + +line-index is a library to convert between text offset and its corresponding line/column. + +## 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 text then various utility functions can be used on it. + +### 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 follows [semver principles]([url](https://semver.org/)https://semver.org/). |
