File: FAQ.md

package info (click to toggle)
rust-nom-locate 4.2.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 192 kB
  • sloc: makefile: 2; sh: 1
file content (26 lines) | stat: -rw-r--r-- 888 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# FAQ

## How to use LocatedSpan with my own input type?

LocatedSpan has been designed to wrap any input type. By default it wraps `&str` and `&[u8]` but it should work with any other types.

To do so, all you need is to ensure that your input type implements these traits:
 - `nom::InputLength`
 - `nom::Slice`
 - `nom::InputIter`
 - `nom::Compare`
 - `nom::Offset`
 - `nom::CompareResult`
 - `nom::FindSubstring`
 - `nom::ParseTo`
 - `nom::AsBytes`

And ensure that what represents a char in your input type implements `nom::FindToken`.

Then you may use all the `impl_*` macros exposed by the library (see the [crate documentation](https://docs.rs/nom_locate/)).

## `get_column` is not accurate

Your input probably doesn't have ASCII characters only. You'd probably better use `get_column_utf8` when your input is contains UTF-8 extensions, having in mind that it is much slower.