Skip to content

Commit 747fa7d

Browse files
line-index: Create README.md
1 parent 6ce3f44 commit 747fa7d

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

lib/line-index/README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# line-index
2+
3+
This crate is developped as part of `rust-analyzer`.
4+
5+
line-index is a library to convert between text offset and its corresponding line/column.
6+
7+
## Installation
8+
9+
To add this crate to a project simply run `cargo add line-index`.
10+
11+
## Usage
12+
13+
The main structure is `LineIndex`. It is constructed with an utf-8 text then various utility functions can be used on it.
14+
15+
### Example
16+
17+
```rust
18+
use line_index::LineIndex;
19+
20+
let line_index = LineIndex::new("This is a\nmulti-line\ntext.");
21+
line_index.line_col(3.into()); // LineCol { line: 0, col: 3 }
22+
line_index.line_col(13.into()); // LineCol { line: 1, col: 3 }
23+
line_index.offset(LineCol { line: 2, col: 3 }); // Some (24)
24+
```
25+
26+
## SemVer
27+
28+
This crate follows [semver principles]([url](https://semver.org/)https://semver.org/).

0 commit comments

Comments
 (0)