Mercurial > lbo > hg > rex
changeset 87:d111720bc9ef
Update to Rust-2018
author | Lewin Bormann <lbo@spheniscida.de> |
---|---|
date | Wed, 09 Dec 2020 17:56:41 +0100 |
parents | 5cfe3b610647 |
children | 437eceef26e0 |
files | Cargo.toml benches/e2e.rs benches/profile.rs src/compile.rs src/matching.rs src/parse.rs src/repr.rs src/state.rs |
diffstat | 8 files changed, 29 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/Cargo.toml Wed Oct 21 11:57:10 2020 +0200 +++ b/Cargo.toml Wed Dec 09 17:56:41 2020 +0100 @@ -6,6 +6,7 @@ license = "MIT" repository = "https://github.com/dermesser/rex" documentation = "https://docs.rs/rex-regex" +edition = "2018" [dependencies]
--- a/benches/e2e.rs Wed Oct 21 11:57:10 2020 +0200 +++ b/benches/e2e.rs Wed Dec 09 17:56:41 2020 +0100 @@ -2,6 +2,8 @@ extern crate bencher; extern crate regex; +use rex_regex as rex; + use bencher::Bencher; fn bench_simple_re(b: &mut Bencher) { @@ -35,6 +37,13 @@ }); } +fn bench_notorious_but_sane(b: &mut Bencher) { + let re = rex::compile("(x+)y").unwrap(); + b.iter(|| { + assert!(rex::match_re(&re, "xxxxxxxxxxy").0); + }); +} + fn bench_notorious_regex_crate(b: &mut Bencher) { let re = regex::Regex::new("(x+x+)+y").unwrap(); b.iter(|| { @@ -54,6 +63,7 @@ bench_simple_re, bench_simple_precompile, bench_notorious, + bench_notorious_but_sane, bench_notorious_regex_crate, bench_regex_crate, bench_simplest_precompile
--- a/benches/profile.rs Wed Oct 21 11:57:10 2020 +0200 +++ b/benches/profile.rs Wed Dec 09 17:56:41 2020 +0100 @@ -1,3 +1,5 @@ +use rex_regex as rex; + fn bench_complicated() { let re_s = "^[hH][eE]l+o +[Ww]orld!?$"; let re = rex::compile(re_s).unwrap();
--- a/src/compile.rs Wed Oct 21 11:57:10 2020 +0200 +++ b/src/compile.rs Wed Dec 09 17:56:41 2020 +0100 @@ -8,9 +8,9 @@ //! //! `start_compile()` is the entry point and public API of this module. -use matcher::{self, wrap_matcher}; -use repr::{AnchorLocation, Pattern, Repetition}; -use state::{State, StateGraph, StateRef, Submatch}; +use crate::matcher::{self, wrap_matcher}; +use crate::repr::{AnchorLocation, Pattern, Repetition}; +use crate::state::{State, StateGraph, StateRef, Submatch}; /// Types implementing Compile can be compiled into a state graph. pub trait Compile {
--- a/src/matching.rs Wed Oct 21 11:57:10 2020 +0200 +++ b/src/matching.rs Wed Dec 09 17:56:41 2020 +0100 @@ -8,8 +8,8 @@ use std::ops::Deref; use std::rc::Rc; -use matcher::Matchee; -use state::{StateGraph, StateRef, Submatch}; +use crate::matcher::Matchee; +use crate::state::{StateGraph, StateRef, Submatch}; /// MatchState stores a state in the overall algorithm while matching a string ("matchee") against /// a regular expression. Every time there is more than one forward state (e.g. optional @@ -215,10 +215,10 @@ #[cfg(test)] mod tests { use super::*; - use compile::*; - use parse; - use repr::*; - use state::*; + use crate::compile::*; + use crate::parse; + use crate::repr::*; + use crate::state::*; fn simple_re0() -> Pattern { parse::parse("aa+$").unwrap()
--- a/src/parse.rs Wed Oct 21 11:57:10 2020 +0200 +++ b/src/parse.rs Wed Dec 09 17:56:41 2020 +0100 @@ -8,7 +8,7 @@ use std::ops::{Index, Range, RangeFull}; use std::str::FromStr; -use repr::{AnchorLocation, Pattern, Repetition}; +use crate::repr::{AnchorLocation, Pattern, Repetition}; /// The entry point for this module: Parse a string into a `Pattern` that can be optimized and/or /// compiled. @@ -377,9 +377,9 @@ #[cfg(test)] mod tests { use super::*; - use compile::*; - use repr::*; - use state::dot; + use crate::compile::*; + use crate::repr::*; + use crate::state::dot; #[test] fn test_find_closing_paren() {
--- a/src/repr.rs Wed Oct 21 11:57:10 2020 +0200 +++ b/src/repr.rs Wed Dec 09 17:56:41 2020 +0100 @@ -167,7 +167,7 @@ #[cfg(test)] mod tests { use super::*; - use state::*; + use crate::state::*; #[test] fn test_repr_optimize() { @@ -255,7 +255,7 @@ ]) } - use compile::start_compile; + use crate::compile::start_compile; #[test] fn test_re1() {
--- a/src/state.rs Wed Oct 21 11:57:10 2020 +0200 +++ b/src/state.rs Wed Dec 09 17:56:41 2020 +0100 @@ -10,7 +10,7 @@ use std::rc::Rc; use std::vec::Vec; -use matcher::{Matchee, Matcher}; +use crate::matcher::{Matchee, Matcher}; /// StateGraph is the graph of states that the interpreter traverses while matching a regular /// expression. It is represented as flat vector. The first element is the State node to start the