Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to 8.0 nom #96

Merged
merged 6 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading