Skip to content

Commit

Permalink
Migrate to 8.0 nom (#96)
Browse files Browse the repository at this point in the history
Thanks to @duncanawoods for the FAQ (#98)
  • Loading branch information
tyranron authored Feb 3, 2025
1 parent 735a7b4 commit e02c099
Show file tree
Hide file tree
Showing 8 changed files with 170 additions and 237 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: CI
on: [push, pull_request]

env:
RUST_MINVERSION: 1.63.0
RUST_MINVERSION: 1.65.0

jobs:
test:
Expand All @@ -16,7 +16,7 @@ jobs:
- stable
- beta
- nightly
- 1.63.0
- 1.65.0

features:
- ''
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# CHANGELOG

## master

Breaking change:

* [Migrate to 8.0 `nom`](https://github.com/fflorent/nom_locate/pull/96)
* Bump up MSRV to 1.65

## v4.2.0

Improvements:
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ readme = "README.md"
repository = "https://github.com/fflorent/nom_locate"
version = "4.2.0"
edition = "2018"
rust-version = "1.63.0"
rust-version = "1.65.0"

[badges.travis-ci]
repository = "fflorent/nom_locate"
Expand All @@ -27,5 +27,5 @@ stable-deref-trait = ["stable_deref_trait"]
[dependencies]
bytecount = "^0.6"
memchr = { version = ">=1.0.1, <3.0.0", default-features = false } # ^1.0.0 + ^2.0
nom = { version = "7", default-features = false }
nom = { version = "8", default-features = false }
stable_deref_trait = { version = "^1", optional = true, default-features = false }
8 changes: 3 additions & 5 deletions FAQ.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# FAQ

## How to use LocatedSpan with my own input type?
## 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.
`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::Input`
- `nom::Compare`
- `nom::Offset`
- `nom::CompareResult`
Expand Down
23 changes: 7 additions & 16 deletions benches/benches.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![feature(test)]
extern crate test;

use nom::Slice;
use nom::Input;
use nom_locate::LocatedSpan;

use test::Bencher;
Expand Down Expand Up @@ -102,7 +102,7 @@ fn bench_slice_full(b: &mut Bencher) {
let input = LocatedSpan::new(TEXT);

b.iter(|| {
input.slice(..);
input.take_from(0);
});
}

Expand All @@ -111,16 +111,7 @@ fn bench_slice_from(b: &mut Bencher) {
let input = LocatedSpan::new(TEXT);

b.iter(|| {
input.slice(200..);
});
}

#[bench]
fn bench_slice_from_zero(b: &mut Bencher) {
let input = LocatedSpan::new(TEXT);

b.iter(|| {
input.slice(0..);
input.take_from(200);
});
}

Expand All @@ -129,7 +120,7 @@ fn bench_slice_to(b: &mut Bencher) {
let input = LocatedSpan::new(TEXT);

b.iter(|| {
input.slice(..200);
input.take(200);
});
}

Expand All @@ -138,7 +129,7 @@ fn bench_slice(b: &mut Bencher) {
let input = LocatedSpan::new(TEXT);

b.iter(|| {
input.slice(200..300);
input.take(300).take_from(200);
});
}

Expand All @@ -148,7 +139,7 @@ fn bench_slice_columns_only(b: &mut Bencher) {
let input = LocatedSpan::new(text.as_str());

b.iter(|| {
input.slice(499..501).get_utf8_column();
input.take(501).take_from(499).get_utf8_column();
});
}

Expand All @@ -161,6 +152,6 @@ fn bench_slice_columns_only_for_ascii_text(b: &mut Bencher) {

assert!(text.is_ascii());
b.iter(|| {
input.slice(500..501).get_column();
input.take(501).take_from(500).get_column();
});
}
Loading

0 comments on commit e02c099

Please sign in to comment.