Skip to content

Commit

Permalink
line-index: Create README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
homersimpsons authored Jan 7, 2024
1 parent 6ce3f44 commit 747fa7d
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions lib/line-index/README.md
Original file line number Diff line number Diff line change
@@ -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/).

0 comments on commit 747fa7d

Please sign in to comment.